Class: ActiveElement::FieldOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/active_element/field_options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ FieldOptions

Returns a new instance of FieldOptions.



16
17
18
19
# File 'lib/active_element/field_options.rb', line 16

def initialize(field)
  @field = field
  @options = {}
end

Instance Attribute Details

#exact_matchObject

Returns the value of attribute exact_match.



3
4
5
# File 'lib/active_element/field_options.rb', line 3

def exact_match
  @exact_match
end

#fieldObject (readonly)

Returns the value of attribute field.



5
6
7
# File 'lib/active_element/field_options.rb', line 5

def field
  @field
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/active_element/field_options.rb', line 3

def options
  @options
end

#typeObject



21
22
23
# File 'lib/active_element/field_options.rb', line 21

def type
  @type || :text_field
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/active_element/field_options.rb', line 3

def value
  @value
end

Class Method Details

.from_state(field, state, record, controller) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/active_element/field_options.rb', line 7

def self.from_state(field, state, record, controller)
  block = state.field_options[field]
  return nil if block.blank?

  field_options = new(field)
  block.call(field_options, record, controller)
  field_options
end