Class: KalibroClient::Entities::Miscellaneous::Base
- Inherits:
-
Object
- Object
- KalibroClient::Entities::Miscellaneous::Base
show all
- Includes:
- HashConverters
- Defined in:
- lib/kalibro_client/entities/miscellaneous/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#convert_to_hash, #date_with_milliseconds, #field_to_hash
#get_xml, #xml_instance_class_name
Constructor Details
#initialize(attributes = {}) ⇒ Base
5
6
7
|
# File 'lib/kalibro_client/entities/miscellaneous/base.rb', line 5
def initialize(attributes={})
attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) }
end
|
Class Method Details
.to_object(value) ⇒ Object
21
22
23
|
# File 'lib/kalibro_client/entities/miscellaneous/base.rb', line 21
def self.to_object value
value.kind_of?(Hash) ? new(value) : value
end
|
Instance Method Details
#==(another) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/kalibro_client/entities/miscellaneous/base.rb', line 25
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 = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/kalibro_client/entities/miscellaneous/base.rb', line 10
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
|