Class: Lolita::Configuration::Field::Enum

Inherits:
Base show all
Defined in:
lib/lolita/configuration/field/enum.rb

Instance Attribute Summary

Attributes inherited from Base

#dbi, #dbi_field, #nested_in

Instance Method Summary collapse

Methods inherited from Base

#find_dbi_field, #initialize, #match_state_of?, #name=, #nested?, #nested_in?, #record_state_matches_with, #set_attributes, #title, #type, #type=

Methods included from Builder

#build, #builder, #builder=, #builder_default_name, #builder_default_options, #builder_default_state

Constructor Details

This class inherits a constructor from Lolita::Configuration::Field::Base

Instance Method Details

#values(value = nil, &block) ⇒ Object



6
7
8
9
# File 'lib/lolita/configuration/field/enum.rb', line 6

def values value=nil, &block
  @values=value || block if value || block_given?
  @values
end

#view_values(view) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/lolita/configuration/field/enum.rb', line 11

def view_values(view)
  record = view.send(:current_form).object
  if values.respond_to?(:call)
    values.call(view)
  else
    values || default_values
  end
end