gbdev-acts_as_dropdown 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 2.0.3
2
+ * fix class Array extension from module in the gem (it worked as a plugin, but failed as a gem)
3
+
1
4
  2.0.2 (2008-10-10)
2
5
  * mirror'd code from http://acts-as-dropdown.googlecode.com/svn/trunk/ (rev 17) to github
3
6
  * added gemspec to build as gem
data/README CHANGED
@@ -4,7 +4,7 @@ This plugin allows any ActiveRecord object to easily be used to create a HTML se
4
4
 
5
5
  The github repository gbdev-acts_as_dropdown was copied from http://acts-as-dropdown.googlecode.com/svn/trunk/ (rev 17) on 2008-10-10
6
6
 
7
- The only modifications in gbdev-acts_as_dropdown are to make the plugin a gem.
7
+ The only current modifications in gbdev-acts_as_dropdown from the original are to make the plugin work as a gem and small reorganizing.
8
8
 
9
9
  == Resources
10
10
 
data/init.rb CHANGED
@@ -1,2 +1 @@
1
- require 'acts_as_dropdown'
2
- require 'dropdown'
1
+ require 'acts_as_dropdown'
@@ -92,7 +92,7 @@ module DeLynnBerry
92
92
  self.include_blank = options.delete(:include_blank)
93
93
  self.find_arguments = options
94
94
  end
95
-
95
+
96
96
  # Examples:
97
97
  #
98
98
  # class State < ActiveRecord::Base
@@ -140,4 +140,31 @@ module DeLynnBerry
140
140
  end
141
141
  end
142
142
 
143
- ActiveRecord::Base.send(:include, DeLynnBerry::Dropdown)
143
+ ActiveRecord::Base.class_eval { include DeLynnBerry::Dropdown }
144
+
145
+ class Array #:nodoc:
146
+ # Collects the contents of the array and creates a new array that can be easily used
147
+ # with the <tt>select</tt> form helper method.
148
+ #
149
+ # == Options
150
+ #
151
+ # * <tt>text</tt> - This is the attribute that will be used as the text/label for the option tag (defaults to 'name').
152
+ # * <tt>value</tt> - This is the attribute that will be used to fill in the option's value parameter (defaults to 'id').
153
+ # * <tt>include_blank</tt> - Specify true if you'd like to have a blank item added to the beginning of your aray, or
154
+ # a string that will be placed in the value attribute of the option group.
155
+ #
156
+ # === Example
157
+ # >> @states = State.find(:all, :order => "id")
158
+ # >> @states.to_dropdown
159
+ # => [["Alabama", 1], ["Alaska", 2], ["Arizona", 3], ["California", 4], ["Colorado", 5]]
160
+ def to_options_for_select(text = :name, value = :id, include_blank = false)
161
+ items = self.collect { |x| [x.send(text.to_sym), x.send(value.to_sym)] }
162
+
163
+ if include_blank
164
+ items.insert(0, include_blank.kind_of?(String) ? [include_blank, ""] : ["", ""])
165
+ end
166
+
167
+ items
168
+ end
169
+ alias :to_dropdown :to_options_for_select
170
+ end
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gbdev-acts_as_dropdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DeLynn Berry
8
+ - John Dell
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
@@ -16,6 +17,7 @@ dependencies: []
16
17
  description: A Rails plugin that adds the ability to easily create an options list out of an ActiveRecord object
17
18
  email:
18
19
  - delynn@gmail.com
20
+ - spovich@gmail.com
19
21
  executables: []
20
22
 
21
23
  extensions: []
@@ -30,7 +32,6 @@ files:
30
32
  - README
31
33
  - RUNNING_UNIT_TESTS
32
34
  - lib/acts_as_dropdown.rb
33
- - lib/dropdown.rb
34
35
  - test/abstract_unit.rb
35
36
  - test/active_record_dropdown_test.rb
36
37
  - test/array_dropdown_test.rb
data/lib/dropdown.rb DELETED
@@ -1,32 +0,0 @@
1
- module DeLynnBerry
2
- module Dropdown
3
- # Collects the contents of the array and creates a new array that can be easily used
4
- # with the <tt>select</tt> form helper method.
5
- #
6
- # == Options
7
- #
8
- # * <tt>text</tt> - This is the attribute that will be used as the text/label for the option tag (defaults to 'name').
9
- # * <tt>value</tt> - This is the attribute that will be used to fill in the option's value parameter (defaults to 'id').
10
- # * <tt>include_blank</tt> - Specify true if you'd like to have a blank item added to the beginning of your aray, or
11
- # a string that will be placed in the value attribute of the option group.
12
- #
13
- # === Example
14
- # >> @states = State.find(:all, :order => "id")
15
- # >> @states.to_dropdown
16
- # => [["Alabama", 1], ["Alaska", 2], ["Arizona", 3], ["California", 4], ["Colorado", 5]]
17
- def to_options_for_select(text = :name, value = :id, include_blank = false)
18
- items = self.collect { |x| [x.send(text.to_sym), x.send(value.to_sym)] }
19
-
20
- if include_blank
21
- items.insert(0, include_blank.kind_of?(String) ? [include_blank, ""] : ["", ""])
22
- end
23
-
24
- items
25
- end
26
- alias :to_dropdown :to_options_for_select
27
- end
28
- end
29
-
30
- class Array #:nodoc:
31
- include DeLynnBerry::Dropdown
32
- end