Class: Trestle::Form::Fields::Select::Choices
- Inherits:
-
Object
- Object
- Trestle::Form::Fields::Select::Choices
- Includes:
- Enumerable
- Defined in:
- lib/trestle/form/fields/select.rb
Overview
Allows an array of model instances (or a scope) to be passed to the select field as the list of choices.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(choices) ⇒ Choices
constructor
A new instance of Choices.
Constructor Details
#initialize(choices) ⇒ Choices
Returns a new instance of Choices.
50 51 52 |
# File 'lib/trestle/form/fields/select.rb', line 50 def initialize(choices) @choices = Array(choices) end |
Instance Method Details
#each ⇒ Object
54 55 56 57 58 |
# File 'lib/trestle/form/fields/select.rb', line 54 def each @choices.each do |option| yield option_text_and_value(option) end end |