class Oura::Model::Base
Oura::Mode::Base is base class for Model
.
Attributes
attrs[R]
to_hash[R]
Public Class Methods
attr_reader(*attrs)
click to toggle source
# File lib/oura/model/base.rb, line 7 def self.attr_reader(*attrs) mod = Module.new do attrs.each do |attribute| define_method attribute do @attrs[attribute.to_sym] end define_method :"#{attribute}?" do !!@attrs[attribute.to_sym] end end end const_set(:Attributes, mod) unless defined? Attributes include mod end
new(attrs = {})
click to toggle source
# File lib/oura/model/base.rb, line 26 def initialize(attrs = {}) @attrs = attrs end
object_from_response(response = {})
click to toggle source
# File lib/oura/model/base.rb, line 22 def self.object_from_response(response = {}) new(response[:body]) end
Public Instance Methods
[](method)
click to toggle source
# File lib/oura/model/base.rb, line 30 def [](method) send(method.to_sym) rescue NoMethodError => e puts e.inspect end
update(attrs)
click to toggle source
# File lib/oura/model/base.rb, line 39 def update(attrs) @attrs.update(attrs) self end
Protected Instance Methods
attr_equal(attr, other)
click to toggle source
@param attr [Symbol] @param other [Square::Base] @return [Boolean]
# File lib/oura/model/base.rb, line 49 def attr_equal(attr, other) self.class == other.class && !other.send(attr).nil? && send(attr) == other.send(attr) end
attrs_equal(other)
click to toggle source
@param other [Square::Base] @return [Boolean]
# File lib/oura/model/base.rb, line 55 def attrs_equal(other) self.class == other.class && !other.attrs.empty? && attrs == other.attrs end