Module: Neo4j::Shared::MassAssignment
- Extended by:
- ActiveSupport::Concern
- Included in:
- Property
- Defined in:
- lib/neo4j/shared/mass_assignment.rb
Overview
MassAssignment allows you to bulk set and update attributes
Including MassAssignment into your model gives it a set of mass assignment methods, similar to those found in ActiveRecord.
Originally part of ActiveAttr, github.com/cgriego/active_attr
Instance Method Summary collapse
-
#assign_attributes(new_attributes = nil) ⇒ Object
Mass update a model’s attributes.
-
#attributes=(new_attributes) ⇒ Object
Mass update a model’s attributes.
-
#initialize(attributes = nil) ⇒ Object
Initialize a model with a set of attributes.
Methods included from ActiveSupport::Concern
Instance Method Details
#assign_attributes(new_attributes = nil) ⇒ Object
Mass update a model’s attributes
25 26 27 28 29 30 31 |
# File 'lib/neo4j/shared/mass_assignment.rb', line 25 def assign_attributes(new_attributes = nil) return unless new_attributes.present? new_attributes.each do |name, value| writer = :"#{name}=" send(writer, value) if respond_to?(writer) end end |
#attributes=(new_attributes) ⇒ Object
Mass update a model’s attributes
41 42 43 |
# File 'lib/neo4j/shared/mass_assignment.rb', line 41 def attributes=(new_attributes) assign_attributes(new_attributes) end |
#initialize(attributes = nil) ⇒ Object
Initialize a model with a set of attributes
53 54 55 56 |
# File 'lib/neo4j/shared/mass_assignment.rb', line 53 def initialize(attributes = nil) assign_attributes(attributes) super() end |