Sha256: 1d328931d350adb22b979daf19190f3e1818326efde220a87bfade981db35c30
Contents?: true
Size: 993 Bytes
Versions: 4
Compression:
Stored size: 993 Bytes
Contents
require "peto/mixin/peto_class" module Peto class User include PetoClass def self.create(hash_args) instance = new instance.name = hash_args["name"] instance.age = hash_args["age"] instance.animals = hash_args["animals"].map {|arg| Animal.create(arg) } return instance end def initialize(args={}) @name = nil @age = nil @animals = [] # for Animal set_args(args) raise_errors unless valid? end attr_reader :name attr_reader :age attr_reader :animals def name=(value) @name = value raise_errors unless valid? end def age=(value) @age = value raise_errors unless valid? end def animals=(value) @animals = value raise_errors unless valid? end def members [:name,:age,:animals] end def types {:name => String,:age => Fixnum,:animals => Array} end def arrays {:animals => Animal} end end end
Version data entries
4 entries across 3 versions & 1 rubygems