Class: Linodians::Employee
- Inherits:
-
Object
- Object
- Linodians::Employee
show all
- Defined in:
- lib/linodians/employee.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ Employee
Returns a new instance of Employee.
7
8
9
|
# File 'lib/linodians/employee.rb', line 7
def initialize(params = {})
@raw = params
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
29
30
31
32
33
|
# File 'lib/linodians/employee.rb', line 29
def method_missing(method, *args, &block)
return super unless @raw.key?(method)
instance_eval "def #{method}() @raw[:'#{method}'] end"
send(method)
end
|
Instance Method Details
#[](value) ⇒ Object
15
16
17
|
# File 'lib/linodians/employee.rb', line 15
def [](value)
@raw[value.to_sym] || @raw[value.to_s]
end
|
#photo ⇒ Object
11
12
13
|
# File 'lib/linodians/employee.rb', line 11
def photo
@photo ||= open(PHOTO_URL % username) { |x| x.read }
end
|
#respond_to?(method, _ = false) ⇒ Boolean
23
24
25
|
# File 'lib/linodians/employee.rb', line 23
def respond_to?(method, _ = false)
@raw.key?(method) || super
end
|
#to_json(*args, &block) ⇒ Object
19
20
21
|
# File 'lib/linodians/employee.rb', line 19
def to_json(*args, &block)
@raw.to_json(*args, &block)
end
|