Module: Summon::Schema::ClassMethods
- Defined in:
- lib/summon/schema.rb
Instance Method Summary collapse
Instance Method Details
#attr(name, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/summon/schema.rb', line 34 def attr(name, = {}) if name.to_s =~ /^(.*)\?$/ name = $1 [:boolean] = true end symbol = name.to_sym @attrs << ::Summon::Schema::Attr.new(symbol, ) define_method(name) do |*args| self.instance_variable_get("@#{name}") end if [:boolean] define_method("#{name}?") do send(name) end end end |
#attrs ⇒ Object
51 52 53 |
# File 'lib/summon/schema.rb', line 51 def attrs @attrs end |
#summon! ⇒ Object
55 56 57 58 |
# File 'lib/summon/schema.rb', line 55 def summon! @attrs = [] attr_reader :src end |