Class: Backstage::Field
- Inherits:
-
Object
- Object
- Backstage::Field
- Defined in:
- lib/backstage/field.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #association ⇒ Object
- #belongs_to? ⇒ Boolean
- #collapsed? ⇒ Boolean
- #container? ⇒ Boolean
- #enum? ⇒ Boolean
- #enum_values ⇒ Object
- #has_many? ⇒ Boolean
- #heading ⇒ Object
-
#initialize(name, type, options = {}) ⇒ Field
constructor
A new instance of Field.
- #partial_path ⇒ Object
- #readonly? ⇒ Boolean
- #row? ⇒ Boolean
- #section? ⇒ Boolean
- #sub_fields ⇒ Object
Constructor Details
#initialize(name, type, options = {}) ⇒ Field
Returns a new instance of Field.
5 6 7 8 9 |
# File 'lib/backstage/field.rb', line 5 def initialize(name, type, = {}) @name = name.to_sym @type = type.to_sym @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/backstage/field.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/backstage/field.rb', line 3 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/backstage/field.rb', line 3 def type @type end |
Instance Method Details
#association ⇒ Object
59 60 61 |
# File 'lib/backstage/field.rb', line 59 def association [:association] end |
#belongs_to? ⇒ Boolean
27 28 29 |
# File 'lib/backstage/field.rb', line 27 def belongs_to? type == :belongs_to end |
#collapsed? ⇒ Boolean
55 56 57 |
# File 'lib/backstage/field.rb', line 55 def collapsed? .fetch(:collapsed, false) end |
#container? ⇒ Boolean
43 44 45 |
# File 'lib/backstage/field.rb', line 43 def container? row? || section? end |
#enum? ⇒ Boolean
19 20 21 |
# File 'lib/backstage/field.rb', line 19 def enum? type == :enum end |
#enum_values ⇒ Object
23 24 25 |
# File 'lib/backstage/field.rb', line 23 def enum_values [:enum_values] || [] end |
#has_many? ⇒ Boolean
31 32 33 |
# File 'lib/backstage/field.rb', line 31 def has_many? type == :has_many end |
#heading ⇒ Object
51 52 53 |
# File 'lib/backstage/field.rb', line 51 def heading [:heading] end |
#partial_path ⇒ Object
11 12 13 |
# File 'lib/backstage/field.rb', line 11 def partial_path [:partial] || "backstage/fields/#{type}" end |
#readonly? ⇒ Boolean
15 16 17 |
# File 'lib/backstage/field.rb', line 15 def readonly? .fetch(:readonly, false) end |
#row? ⇒ Boolean
35 36 37 |
# File 'lib/backstage/field.rb', line 35 def row? type == :row end |
#section? ⇒ Boolean
39 40 41 |
# File 'lib/backstage/field.rb', line 39 def section? type == :section end |
#sub_fields ⇒ Object
47 48 49 |
# File 'lib/backstage/field.rb', line 47 def sub_fields [:sub_fields] || [] end |