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.


34
35
36
# File 'lib/trestle/form/fields/select.rb', line 34

def initialize(choices)
  @choices = Array(choices)
end

Instance Method Details

#eachObject


38
39
40
41
42
# File 'lib/trestle/form/fields/select.rb', line 38

def each
  @choices.each do |option|
    yield option_text_and_value(option)
  end
end