Class: Pawnee::Actions::BaseModel
- Inherits:
-
Object
- Object
- Pawnee::Actions::BaseModel
- Includes:
- ActiveModel::Dirty
- Defined in:
- lib/pawnee/pawnee/actions/base_model.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#new_record ⇒ Object
Returns the value of attribute new_record.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#new_record ⇒ Object
Returns the value of attribute new_record.
8 9 10 |
# File 'lib/pawnee/pawnee/actions/base_model.rb', line 8 def new_record @new_record end |
Class Method Details
.change_attr_accessor(method_names) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pawnee/pawnee/actions/base_model.rb', line 20 def self.change_attr_accessor(method_names) [method_names].flatten.each do |method_name| self.send(:define_method, :"#{method_name}") do return instance_variable_get("@#{method_name}") end self.send(:define_method, :"#{method_name}=") do |val| self.send(:"#{method_name}_will_change!") unless val == instance_variable_get("@#{method_name}") instance_variable_set("@#{method_name}", val) end end end |
Instance Method Details
#new_record? ⇒ Boolean
10 11 12 |
# File 'lib/pawnee/pawnee/actions/base_model.rb', line 10 def new_record? !!@new_record end |
#update_attributes(attributes) ⇒ Object
14 15 16 17 18 |
# File 'lib/pawnee/pawnee/actions/base_model.rb', line 14 def update_attributes(attributes) attributes.each_pair do |key,value| self.send(:"#{key}=", value) if self.respond_to?(:"#{key}=") end end |