Module: Typhoid::Attributes
- Included in:
- Resource
- Defined in:
- lib/typhoid/attributes.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #after_build(response, exception = nil) ⇒ Object
- #attributes ⇒ Object
- #load_values(params = {}) ⇒ Object
- #read_attribute(name) ⇒ Object (also: #[])
Class Method Details
.included(base) ⇒ Object
26 27 28 |
# File 'lib/typhoid/attributes.rb', line 26 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#after_build(response, exception = nil) ⇒ Object
17 18 19 |
# File 'lib/typhoid/attributes.rb', line 17 def after_build(response, exception = nil) assign_request_error(exception) if !response.success? || !exception.nil? end |
#attributes ⇒ Object
7 8 9 10 |
# File 'lib/typhoid/attributes.rb', line 7 def attributes @attributes ||= {} @attributes end |
#load_values(params = {}) ⇒ Object
3 4 5 |
# File 'lib/typhoid/attributes.rb', line 3 def load_values(params = {}) @attributes = Hash[params.map { |key, value| [key.to_s, value] }] end |
#read_attribute(name) ⇒ Object Also known as: []
12 13 14 |
# File 'lib/typhoid/attributes.rb', line 12 def read_attribute(name) attributes[name.to_s] end |