Module: Ixtlan::Babel::ModelSerializer::ClassMethods
- Defined in:
- lib/ixtlan/babel/model_serializer.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, type = nil) ⇒ Object
78 79 80 |
# File 'lib/ixtlan/babel/model_serializer.rb', line 78 def attribute( name, type = nil ) attributes[ name.to_sym ] = new_instance( type ) end |
#attributes(*args) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/ixtlan/babel/model_serializer.rb', line 82 def attributes( *args ) if args.size == 0 @attributes ||= (superclass.attributes.dup rescue nil) || {} else args.each { |a| attribute( a ) } end end |
#new_instance(type) ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ixtlan/babel/model_serializer.rb', line 90 def new_instance( type ) case type when Array [ type[ 0 ].new ] when NilClass nil else type.new end end |