Module: Reaction::HasAttributes
- Included in:
- Action
- Defined in:
- lib/reaction/has_attributes.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/reaction/has_attributes.rb', line 3 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#attributes ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/reaction/has_attributes.rb', line 27 def attributes ret = {} self.class.attributes.each do |name| ret[name] = send(name) end ret end |
#set_attributes(attributes = {}) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/reaction/has_attributes.rb', line 35 def set_attributes(attributes = {}) attributes.each do |key, value| if self.class.attributes.include?(key) send("#{key}=", value) end end end |
#validate_attributes ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/reaction/has_attributes.rb', line 43 def validate_attributes self.class.attributes.each do |attribute| unless send(attribute) # This is a server side error - we didn't set a valid attribute # for some reason, and attributes are things the server sets. failure(AttributeError.new(attribute)) and return false end end end |