Class: SimpleFormObject::Attribute

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type = nil, options) ⇒ Attribute



50
51
52
53
54
55
56
# File 'lib/simple_form_object.rb', line 50

def initialize(name, type = nil, options)
  @name = name
  @type = type || :string
  @options = options

  extract_options
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



58
59
60
# File 'lib/simple_form_object.rb', line 58

def name
  @name
end

#optionsObject

Returns the value of attribute options.



58
59
60
# File 'lib/simple_form_object.rb', line 58

def options
  @options
end

#typeObject

Returns the value of attribute type.



58
59
60
# File 'lib/simple_form_object.rb', line 58

def type
  @type
end

Instance Method Details

#apply_default_to(form) ⇒ Object



64
65
66
67
68
# File 'lib/simple_form_object.rb', line 64

def apply_default_to(form)
  if form.send(@name).nil?
    form.send("#{@name}=", @default) if @apply_default
  end
end

#fake_columnObject



60
61
62
# File 'lib/simple_form_object.rb', line 60

def fake_column
  self
end