Class: Blastramp::Entity
- Inherits:
-
Object
show all
- Defined in:
- lib/blastramp/entity.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(values = {}) ⇒ Entity
27
28
29
30
|
# File 'lib/blastramp/entity.rb', line 27
def initialize(values = {})
initialize_defaults
update_properties(values)
end
|
Instance Attribute Details
#session ⇒ Object
4
5
6
|
# File 'lib/blastramp/entity.rb', line 4
def session
@session
end
|
Class Method Details
.has_properties(*properties) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/blastramp/entity.rb', line 7
def has_properties(*properties)
@properties = properties
properties.each do |property|
unless instance_methods.collect(&:to_s).include?(property.to_s)
define_method "#{property}" do
instance_variable_get("@#{property}")
end
end
attr_writer property
end
end
|
.properties ⇒ Object
22
23
24
|
# File 'lib/blastramp/entity.rb', line 22
def properties
@properties || []
end
|
Instance Method Details
#initialize_defaults ⇒ Object
32
33
34
|
# File 'lib/blastramp/entity.rb', line 32
def initialize_defaults
nil
end
|
#inspect ⇒ Object
36
37
38
39
|
# File 'lib/blastramp/entity.rb', line 36
def inspect
props = self.class.properties.collect { |p| "#{p}=#{self.send(p).inspect}" }
"#<#{self.class}:#{self.object_id}, #{props.join(', ')}>"
end
|
#soap_data ⇒ Object
Returns OrderedHash with the data structure to send to the API
49
50
|
# File 'lib/blastramp/entity.rb', line 49
def soap_data
end
|
#update_properties(hash) ⇒ Object
Updates properties of Entity with the values from hash
42
43
44
45
46
|
# File 'lib/blastramp/entity.rb', line 42
def update_properties(hash)
hash.each do |key, value|
self.send("#{key}=", value)
end
end
|