class MiniModel
Public Class Methods
new(attributes)
click to toggle source
# File lib/minimodel.rb, line 4 def initialize(attributes) @attributes = attributes.to_hash end
Public Instance Methods
eql?(object)
click to toggle source
# File lib/minimodel.rb, line 12 def eql?(object) object.class == self.class && object.hash == self.hash end
hash()
click to toggle source
# File lib/minimodel.rb, line 8 def hash @attributes.hash end
method_missing(symbol, *args, &block)
click to toggle source
Calls superclass method
# File lib/minimodel.rb, line 28 def method_missing(symbol, *args, &block) if @attributes.key?(symbol) && args.empty? && block.nil? return @attributes[symbol] else super symbol, *args, &block end end
read_attribute(name)
click to toggle source
# File lib/minimodel.rb, line 24 def read_attribute(name) @attributes[name] end
respond_to_missing?(symbol, include_private = false)
click to toggle source
# File lib/minimodel.rb, line 36 def respond_to_missing?(symbol, include_private = false) @attributes.key?(symbol) end
to_hash()
click to toggle source
# File lib/minimodel.rb, line 16 def to_hash @attributes end
to_json()
click to toggle source
# File lib/minimodel.rb, line 20 def to_json @attributes.to_json end