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
- #enum? ⇒ Boolean
- #enum_values ⇒ Object
- #has_many? ⇒ Boolean
-
#initialize(name, type, options = {}) ⇒ Field
constructor
A new instance of Field.
- #partial_path ⇒ Object
- #readonly? ⇒ Boolean
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
35 36 37 |
# File 'lib/backstage/field.rb', line 35 def association [:association] end |
#belongs_to? ⇒ Boolean
27 28 29 |
# File 'lib/backstage/field.rb', line 27 def belongs_to? type == :belongs_to 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 |
#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 |