Class: BootstrapAdmin::Attribute
- Inherits:
-
Object
- Object
- BootstrapAdmin::Attribute
- Defined in:
- lib/bootstrap_admin/attribute.rb
Overview
BootstrapAdmin::Attribute represents a model attribute and stores its name, human_name and a computed “type” which can be one of:
:association
:attribute
:none
(take a look at active_record_extensions).
This is used to build UI elements, see:
app/views/defaults/show
app/views/defaults/form
app/views/defaults/index
Instance Attribute Summary collapse
-
#human_name ⇒ Object
readonly
Returns the value of attribute human_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#association? ⇒ true, false
True if type is :association, false otherwise.
-
#attribute? ⇒ true, false
True if type is :attribute, false otherwise.
-
#initialize(name, human_name, type) ⇒ Attribute
constructor
A new instance of Attribute.
-
#to_s ⇒ String
The attribute’s name.
-
#to_sym ⇒ Symbol
The attribute’s name, but as a Symbol.
Constructor Details
#initialize(name, human_name, type) ⇒ Attribute
Returns a new instance of Attribute.
18 19 20 |
# File 'lib/bootstrap_admin/attribute.rb', line 18 def initialize name, human_name, type @name, @human_name, @type = name, human_name, type end |
Instance Attribute Details
#human_name ⇒ Object (readonly)
Returns the value of attribute human_name.
16 17 18 |
# File 'lib/bootstrap_admin/attribute.rb', line 16 def human_name @human_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/bootstrap_admin/attribute.rb', line 16 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
16 17 18 |
# File 'lib/bootstrap_admin/attribute.rb', line 16 def type @type end |
Instance Method Details
#association? ⇒ true, false
Returns true if type is :association, false otherwise.
29 |
# File 'lib/bootstrap_admin/attribute.rb', line 29 def association?; :association == type; end |
#attribute? ⇒ true, false
Returns true if type is :attribute, false otherwise.
32 |
# File 'lib/bootstrap_admin/attribute.rb', line 32 def attribute?; :attribute == type; end |
#to_s ⇒ String
Returns the attribute’s name.
23 |
# File 'lib/bootstrap_admin/attribute.rb', line 23 def to_s; name.to_s; end |
#to_sym ⇒ Symbol
Returns the attribute’s name, but as a Symbol.
26 |
# File 'lib/bootstrap_admin/attribute.rb', line 26 def to_sym; to_s.to_sym; end |