class Damsel::Attribute
Attributes
block[R]
default[R]
klass[R]
name[R]
type[R]
Public Class Methods
new(name, options={})
click to toggle source
# File lib/damsel/attribute.rb, line 5 def initialize(name, options={}) o = { child: false, default: nil, type: String, klass: nil, many: false, named: false, block: nil, }.merge(options) @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
Public Instance Methods
child?()
click to toggle source
# File lib/damsel/attribute.rb, line 35 def child? @child end
many?()
click to toggle source
# File lib/damsel/attribute.rb, line 39 def many? @many end
named?()
click to toggle source
# File lib/damsel/attribute.rb, line 43 def named? @named end