Class: TimelyApp::Record
- Inherits:
-
Object
show all
- Defined in:
- lib/timely-app/record.rb
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Record
Returns a new instance of Record.
3
4
5
|
# File 'lib/timely-app/record.rb', line 3
def initialize(attributes = {})
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/timely-app/record.rb', line 15
def method_missing(name, *args, &block)
if @attributes.has_key?(name) && args.empty? && block.nil?
return @attributes[name]
else
super name, *args, &block
end
end
|
Instance Method Details
#[](name) ⇒ Object
7
8
9
|
# File 'lib/timely-app/record.rb', line 7
def [](name)
@attributes[name]
end
|
#[]=(name, value) ⇒ Object
11
12
13
|
# File 'lib/timely-app/record.rb', line 11
def []=(name, value)
@attributes[name] = value
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
23
24
25
|
# File 'lib/timely-app/record.rb', line 23
def respond_to_missing?(name, include_private = false)
@attributes.has_key?(name)
end
|
#to_h ⇒ Object
27
28
29
|
# File 'lib/timely-app/record.rb', line 27
def to_h
@attributes
end
|