Class: Phlexi::Form::GroupedChoicesMapper
- Inherits:
-
Object
- Object
- Phlexi::Form::GroupedChoicesMapper
- Includes:
- Enumerable
- Defined in:
- lib/phlexi/form/grouped_choices_mapper.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(collection, group_method:, group_label_method: :to_s, label_method: nil, value_method: nil) ⇒ GroupedChoicesMapper
constructor
A new instance of GroupedChoicesMapper.
-
#values ⇒ Array<String>
An array of all choice values.
Constructor Details
#initialize(collection, group_method:, group_label_method: :to_s, label_method: nil, value_method: nil) ⇒ GroupedChoicesMapper
Returns a new instance of GroupedChoicesMapper.
8 9 10 11 12 13 14 |
# File 'lib/phlexi/form/grouped_choices_mapper.rb', line 8 def initialize(collection, group_method:, group_label_method: :to_s, label_method: nil, value_method: nil) @collection = collection @group_method = group_method @group_label_method = group_label_method @label_method = label_method @value_method = value_method end |
Instance Method Details
#each ⇒ Object
16 17 18 |
# File 'lib/phlexi/form/grouped_choices_mapper.rb', line 16 def each(&) grouped_choices.each(&) end |
#values ⇒ Array<String>
Returns An array of all choice values.
21 22 23 |
# File 'lib/phlexi/form/grouped_choices_mapper.rb', line 21 def values @values ||= grouped_choices.values.flat_map(&:values) end |