Class: FaaStRuby::BaseObject
- Inherits:
-
Object
- Object
- FaaStRuby::BaseObject
show all
- Defined in:
- lib/faastruby/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) {|_self| ... } ⇒ BaseObject
Returns a new instance of BaseObject.
41
42
43
44
45
46
|
# File 'lib/faastruby/base.rb', line 41
def initialize(params = {}, &block)
@errors = []
@api = API.new
self.mass_assign(params) if params
yield self if block_given?
end
|
Instance Method Details
#assign_attributes(params = {}) {|_self| ... } ⇒ Object
48
49
50
51
|
# File 'lib/faastruby/base.rb', line 48
def assign_attributes(params = {}, &block)
self.mass_assign(params) if params
yield self if block_given?
end
|
#attributes=(params) ⇒ Object
53
54
55
|
# File 'lib/faastruby/base.rb', line 53
def attributes=(params)
assign_attributes(params)
end
|
#call_api ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/faastruby/base.rb', line 57
def call_api
response = yield
@status_code = response.code
@errors += response.errors if response.errors.any?
response
end
|
#mass_assign(attrs) ⇒ Object
65
66
67
68
69
|
# File 'lib/faastruby/base.rb', line 65
def mass_assign(attrs)
attrs.each do |key, value|
self.public_send("#{key}=", value)
end
end
|