class KalibroClient::Entities::Miscellaneous::Base
Public Class Methods
new(attributes={})
click to toggle source
# File lib/kalibro_client/entities/miscellaneous/base.rb, line 7 def initialize(attributes={}) attributes.each { |field, value| send("#{field}=", value) if self.class.valid?(field) } end
to_object(value)
click to toggle source
# File lib/kalibro_client/entities/miscellaneous/base.rb, line 23 def self.to_object value value.kind_of?(Hash) ? new(value) : value end
Public Instance Methods
==(another)
click to toggle source
# File lib/kalibro_client/entities/miscellaneous/base.rb, line 27 def ==(another) unless self.class == another.class return false end self.variable_names.each do |name| next if name == "created_at" or name == "updated_at" unless self.send("#{name}") == another.send("#{name}") then return false end end return true end
to_hash(options={})
click to toggle source
# File lib/kalibro_client/entities/miscellaneous/base.rb, line 12 def to_hash(options={}) hash = Hash.new excepts = options[:except].nil? ? [] : options[:except] fields.each do |field| hash = field_to_hash(field).merge(hash) if !excepts.include?(field) end hash end
Protected Instance Methods
fields()
click to toggle source
# File lib/kalibro_client/entities/miscellaneous/base.rb, line 44 def fields instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '') } end
instance_variable_names()
click to toggle source
# File lib/kalibro_client/entities/miscellaneous/base.rb, line 48 def instance_variable_names instance_variables.map { |var| var.to_s } end
variable_names()
click to toggle source
# File lib/kalibro_client/entities/miscellaneous/base.rb, line 52 def variable_names instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '') } end