Class: Trestle::Form::Fields::Select::Choices

Inherits:
Object
  • Object
show all
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

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

#eachObject



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