Module: Golden::Setting::FormOption

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/golden/setting/form_option.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#field_typeObject



40
41
42
# File 'lib/golden/setting/form_option.rb', line 40

def field_type
  form_options[:type]
end

#field_type=(new_value) ⇒ Object



44
45
46
47
# File 'lib/golden/setting/form_option.rb', line 44

def field_type= new_value
  return unless new_value
  self.form_options[:type] = new_value.to_sym
end

#field_valuesObject



49
50
51
52
53
54
55
56
# File 'lib/golden/setting/form_option.rb', line 49

def field_values
  case form_options[:collection]
  when String
    eval form_options[:collection]
  else
    form_options[:collection]
  end
end

#field_values=(new_value) ⇒ Object



58
59
60
61
# File 'lib/golden/setting/form_option.rb', line 58

def field_values= new_value
  return unless new_value
  self.form_options[:collection] = eval(new_value)
end

#form_optionsObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/golden/setting/form_option.rb', line 29

def form_options
  case self[:form_options]
  when String
    YAML::load self[:form_options]
  when Hash
    super
  else
    self[:form_options] = default_form_options.dup
  end
end