Class: RhoGallery::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/rhogallery/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(data = {}) ⇒ Base
Returns a new instance of Base.
3
4
5
6
|
# File 'lib/rhogallery/base.rb', line 3
def initialize(data = {})
@attributes = data
@errors = String.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/rhogallery/base.rb', line 67
def method_missing(method_sym, *arguments, &block)
@attributes = RhoGallery.prepare_hash(@attributes)
if method_sym.to_s.slice("=")
att = method_sym.to_s.split("=").first.strip
if @attributes[att.to_sym]
@attributes[att.to_sym] = arguments.join
else
@attributes.merge!({att.to_sym => arguments.join})
end
else
att = @attributes[method_sym]
if att
att
else
super
end
end
end
|
Instance Method Details
#errors ⇒ Object
12
13
14
|
# File 'lib/rhogallery/base.rb', line 12
def errors
@errors.strip
end
|
#id ⇒ Object
8
9
10
|
# File 'lib/rhogallery/base.rb', line 8
def id
@attributes[:id]
end
|