Sha256: 4c1b7ca8aaa1cc5c9be415a79cf2ed8aa10d9665ab026ae943feb454961ad9e5
Contents?: true
Size: 875 Bytes
Versions: 13
Compression:
Stored size: 875 Bytes
Contents
unless defined?(User) class User attr_accessor :age, :city, :name, :first, :float, :hobbies DEFAULT_AGE = 24 DEFAULT_CITY = 'irvine' DEFAULT_NAME = 'rabl' DEFAULT_FIRST = 'bob' DEFAULT_FLOAT = 1234.56 DEFAULT_HOBBIES = ['Photography'] def initialize(attributes={}) %w(age city name first float hobbies).each do |attr| self.send "#{attr}=", (attributes.has_key?(attr.to_sym) ? attributes[attr.to_sym] : self.class.const_get("DEFAULT_#{attr.upcase}")) end self.hobbies = self.hobbies.map { |h| Hobby.new(h) } end end class Hobby attr_accessor :name def initialize(name); @name = name; end end end unless defined?(NestedScope::User) module NestedScope class User def controller; self; end def controller_name; self.class.name.downcase; end end end end
Version data entries
13 entries across 13 versions & 1 rubygems