Class: Agendrix::Nethris::Entity
- Inherits:
-
Object
- Object
- Agendrix::Nethris::Entity
show all
- Defined in:
- lib/agendrix/nethris/entity.rb
Instance Method Summary
collapse
Constructor Details
#initialize(client, attributes) ⇒ Entity
Returns a new instance of Entity.
4
5
6
7
|
# File 'lib/agendrix/nethris/entity.rb', line 4
def initialize(client, attributes)
@client = client
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/agendrix/nethris/entity.rb', line 15
def method_missing(method_name)
method_name_s = method_name.to_s
if @attributes.key?(method_name_s.upcase)
@attributes[method_name_s.upcase]
elsif @attributes.key?(method_name_s)
@attributes[method_name_s]
else
super
end
end
|
Instance Method Details
#inspect ⇒ Object
9
10
11
12
13
|
# File 'lib/agendrix/nethris/entity.rb', line 9
def inspect
variables = self.instance_variables - [:"@client"]
variables.map! { |v| "#{v}=#{self.instance_eval(v.to_s)}" }
"#<#{self.class} #{variables.join(', ')}>"
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
27
28
29
30
|
# File 'lib/agendrix/nethris/entity.rb', line 27
def respond_to_missing?(method_name, include_private = false)
method_name_s = method_name.to_s
@attributes.key?(method_name_s) || @attributes.key?(method_name_s.upcase) || super
end
|