Class: CmAdmin::Models::Column
- Inherits:
-
Object
- Object
- CmAdmin::Models::Column
- Defined in:
- lib/cm_admin/models/column.rb
Instance Attribute Summary collapse
-
#cm_css_class ⇒ Object
Returns the value of attribute cm_css_class.
-
#custom_method ⇒ Object
Returns the value of attribute custom_method.
-
#display_if ⇒ Object
Returns the value of attribute display_if.
-
#drawer_partial ⇒ Object
Returns the value of attribute drawer_partial.
-
#exportable ⇒ Object
Returns the value of attribute exportable.
-
#field_name ⇒ Object
Returns the value of attribute field_name.
-
#field_type ⇒ Object
Returns the value of attribute field_type.
-
#format ⇒ Object
Returns the value of attribute format.
-
#header ⇒ Object
Returns the value of attribute header.
-
#height ⇒ Object
Returns the value of attribute height.
-
#helper_method ⇒ Object
Returns the value of attribute helper_method.
-
#link ⇒ Object
Returns the value of attribute link.
-
#lockable ⇒ Object
Returns the value of attribute lockable.
-
#managable ⇒ Object
Returns the value of attribute managable.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#round ⇒ Object
Returns the value of attribute round.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
-
#tag_class ⇒ Object
Returns the value of attribute tag_class.
-
#url ⇒ Object
Returns the value of attribute url.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#format_header ⇒ Object
returns a string value as a header (either field_name or value present in header attribute).
-
#initialize(field_name, attributes = {}) ⇒ Column
constructor
A new instance of Column.
- #set_default_values ⇒ Object
Constructor Details
#initialize(field_name, attributes = {}) ⇒ Column
Returns a new instance of Column.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cm_admin/models/column.rb', line 7 def initialize(field_name, attributes = {}) @field_name = field_name set_default_values attributes.each do |key, value| self.send("#{key.to_s}=", value) end #formatting header (either field_name or value present in header attribute) self.send("header=", format_header) 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
#cm_css_class ⇒ Object
Returns the value of attribute cm_css_class.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def cm_css_class @cm_css_class end |
#custom_method ⇒ Object
Returns the value of attribute custom_method.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def custom_method @custom_method end |
#display_if ⇒ Object
Returns the value of attribute display_if.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def display_if @display_if end |
#drawer_partial ⇒ Object
Returns the value of attribute drawer_partial.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def drawer_partial @drawer_partial end |
#exportable ⇒ Object
Returns the value of attribute exportable.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def exportable @exportable end |
#field_name ⇒ Object
Returns the value of attribute field_name.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def field_name @field_name end |
#field_type ⇒ Object
Returns the value of attribute field_type.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def field_type @field_type end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def format @format end |
#header ⇒ Object
Returns the value of attribute header.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def header @header end |
#height ⇒ Object
Returns the value of attribute height.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def height @height end |
#helper_method ⇒ Object
Returns the value of attribute helper_method.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def helper_method @helper_method end |
#link ⇒ Object
Returns the value of attribute link.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def link @link end |
#lockable ⇒ Object
Returns the value of attribute lockable.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def lockable @lockable end |
#managable ⇒ Object
Returns the value of attribute managable.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def managable @managable end |
#prefix ⇒ Object
Returns the value of attribute prefix.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def prefix @prefix end |
#round ⇒ Object
Returns the value of attribute round.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def round @round end |
#suffix ⇒ Object
Returns the value of attribute suffix.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def suffix @suffix end |
#tag_class ⇒ Object
Returns the value of attribute tag_class.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def tag_class @tag_class end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def url @url end |
#width ⇒ Object
Returns the value of attribute width.
4 5 6 |
# File 'lib/cm_admin/models/column.rb', line 4 def width @width end |
Class Method Details
.find_by(model, search_hash) ⇒ Object
34 35 36 |
# File 'lib/cm_admin/models/column.rb', line 34 def find_by(model, search_hash) model.available_fields.find { |i| i.name == search_hash[:name] } end |
Instance Method Details
#format_header ⇒ Object
returns a string value as a header (either field_name or value present in header attribute)
22 23 24 |
# File 'lib/cm_admin/models/column.rb', line 22 def format_header self.header.present? ? self.header.to_s.gsub(/_/, ' ')&.upcase : self.field_name.to_s.gsub(/_/, ' ').upcase end |
#set_default_values ⇒ Object
26 27 28 29 30 31 |
# File 'lib/cm_admin/models/column.rb', line 26 def set_default_values self.exportable = true self.managable = true self.lockable = false self.tag_class = {} end |