Class: Damsel::Attribute
- Inherits:
-
Object
- Object
- Damsel::Attribute
- Defined in:
- lib/damsel/attribute.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #child? ⇒ Boolean
-
#initialize(name, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #many? ⇒ Boolean
- #named? ⇒ Boolean
Constructor Details
#initialize(name, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/damsel/attribute.rb', line 5 def initialize(name, ={}) o = { child: false, default: nil, type: String, klass: nil, many: false, named: false, block: nil, }.merge() @name = name.to_sym @child = o[:child] @default = o[:default] @named = o[:named] @many = o[:many] @klass = o[:klass] @type = o[:type] @block = o[:block] if type == Array @default = [] elsif type == :child if many? @default = [] else @default = {} end end end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/damsel/attribute.rb', line 3 def block @block end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
3 4 5 |
# File 'lib/damsel/attribute.rb', line 3 def default @default end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/damsel/attribute.rb', line 3 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/damsel/attribute.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/damsel/attribute.rb', line 3 def type @type end |
Instance Method Details
#child? ⇒ Boolean
35 36 37 |
# File 'lib/damsel/attribute.rb', line 35 def child? @child end |
#many? ⇒ Boolean
39 40 41 |
# File 'lib/damsel/attribute.rb', line 39 def many? @many end |
#named? ⇒ Boolean
43 44 45 |
# File 'lib/damsel/attribute.rb', line 43 def named? @named end |