Class: Paytunia::Api::Base
- Inherits:
-
Object
- Object
- Paytunia::Api::Base
show all
- Defined in:
- lib/paytunia/models/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args) ⇒ Base
Returns a new instance of Base.
4
5
6
7
8
9
|
# File 'lib/paytunia/models/base.rb', line 4
def initialize(args)
args.each do |k, v|
val = (k =~ /_at$/) ? DateTime.parse(v) : v
send("#{k}=", val)
end
end
|
Class Method Details
.inherited(child) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/paytunia/models/base.rb', line 11
def self.inherited(child)
child.instance_eval do
def attrs(*args)
attr_accessor *args
@attr_list = args
end
end
end
|
Instance Method Details
#to_json(*args) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/paytunia/models/base.rb', line 20
def to_json(*args)
h = self.class.instance_variable_get(:@attr_list).inject({}) do |memo, att|
memo[att] = send(att)
memo
end
JSON.generate(h)
end
|