Class: Rumember::Abstract
- Inherits:
-
Object
- Object
- Rumember::Abstract
show all
- Includes:
- Dispatcher
- Defined in:
- lib/rumember/abstract.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Dispatcher
#dispatch, #lists, #locations, #transaction_dispatch
Constructor Details
#initialize(parent, attributes) ⇒ Abstract
Returns a new instance of Abstract.
7
8
9
10
|
# File 'lib/rumember/abstract.rb', line 7
def initialize(parent, attributes)
@parent = parent
@attributes = attributes
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
5
6
7
|
# File 'lib/rumember/abstract.rb', line 5
def parent
@parent
end
|
Class Method Details
.boolean_reader(*methods) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/rumember/abstract.rb', line 35
def self.boolean_reader(*methods)
reader(*methods) do |value|
value == '1' ? true : false
end
methods.each do |method|
alias_method "#{method}?", method
end
end
|
.integer_reader(*methods) ⇒ Object
29
30
31
32
33
|
# File 'lib/rumember/abstract.rb', line 29
def self.integer_reader(*methods)
reader(*methods) do |value|
Integer(value) unless value.kind_of?(String) && value.empty?
end
end
|
.reader(*methods, &block) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rumember/abstract.rb', line 16
def self.reader(*methods, &block)
methods.each do |method|
define_method(method) do
value = @attributes[method.to_s]
if block && !value.nil?
yield value
else
value
end
end
end
end
|
.time_reader(*methods) ⇒ Object
44
45
46
47
48
|
# File 'lib/rumember/abstract.rb', line 44
def self.time_reader(*methods)
reader(*methods) do |value|
Time.parse(value) unless value.empty?
end
end
|
Instance Method Details
#params ⇒ Object
12
13
14
|
# File 'lib/rumember/abstract.rb', line 12
def params
{}
end
|