Sha256: e9e72b5e5799036b6e2f52fc004551912a7f1b3481b88de7bc9969e7caf05de9

Contents?: true

Size: 986 Bytes

Versions: 6

Compression:

Stored size: 986 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={})
      self.age     = attributes[:age]     || DEFAULT_AGE
      self.city    = attributes[:city]    || DEFAULT_CITY
      self.name    = attributes[:name]    || DEFAULT_NAME
      self.first   = attributes[:first]   || DEFAULT_FIRST
      self.float   = attributes[:float]   || DEFAULT_FLOAT
      self.hobbies = (attributes[:hobbies] || DEFAULT_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

6 entries across 6 versions & 1 rubygems

Version Path
rabl-0.8.3 test/models/user.rb
rabl-0.8.2 test/models/user.rb
rabl-0.8.1 test/models/user.rb
rabl-0.8.0 test/models/user.rb
rabl-0.7.10 test/models/user.rb
rabl-0.7.9 test/models/user.rb