Class: Artisan::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/artisan/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
17
18
19
20
21
|
# File 'lib/artisan/base.rb', line 17
def initialize(attributes = {})
attributes.each do |key, value|
send("#{key}=", value) if respond_to?("#{key}=")
end
end
|
Class Method Details
.hash_attr_accessor(*accessors) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/artisan/base.rb', line 4
def self.hash_attr_accessor(*accessors)
accessors.each do |m|
define_method(m) do
@attributes[m]
end
define_method("#{m}=") do |value|
@attributes = {} if @attributes.nil?
@attributes[m] = value
end
end
end
|
Instance Method Details
#attributes ⇒ Object
23
24
25
|
# File 'lib/artisan/base.rb', line 23
def attributes
return @attributes.dup
end
|