Class: CmAdmin::Models::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/cm_admin/models/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_name, attributes = {}) ⇒ Field

Returns a new instance of Field.



8
9
10
11
12
13
14
15
16
17
# File 'lib/cm_admin/models/field.rb', line 8

def initialize(field_name, attributes = {})
  @field_name = field_name
  set_default_values
  attributes.each do |key, value|
    self.send("#{key.to_s}=", value)
  end
  self.height = 50 if self.field_type == :image && self.height.nil?
  self.width = 50 if self.field_type == :image && self.width.nil?
  self.display_if = lambda { |arg| return true } if self.display_if.nil?
end

Instance Attribute Details

Returns the value of attribute custom_link.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def custom_link
  @custom_link
end

#display_ifObject

Returns the value of attribute display_if.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def display_if
  @display_if
end

#field_nameObject

Returns the value of attribute field_name.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def field_name
  @field_name
end

#field_typeObject

Returns the value of attribute field_type.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def field_type
  @field_type
end

#formatObject

Returns the value of attribute format.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def format
  @format
end

#headerObject

Returns the value of attribute header.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def header
  @header
end

#heightObject

Returns the value of attribute height.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def height
  @height
end

#helper_methodObject

Returns the value of attribute helper_method.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def helper_method
  @helper_method
end

#labelObject

Returns the value of attribute label.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def label
  @label
end

#precisionObject

Returns the value of attribute precision.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def precision
  @precision
end

#prefixObject

Returns the value of attribute prefix.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def prefix
  @prefix
end

#previewObject

Returns the value of attribute preview.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def preview
  @preview
end

#suffixObject

Returns the value of attribute suffix.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def suffix
  @suffix
end

#tag_classObject

Returns the value of attribute tag_class.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def tag_class
  @tag_class
end

#widthObject

Returns the value of attribute width.



5
6
7
# File 'lib/cm_admin/models/field.rb', line 5

def width
  @width
end

Instance Method Details

#set_default_valuesObject



19
20
21
# File 'lib/cm_admin/models/field.rb', line 19

def set_default_values
  self.tag_class = {}
end