Module: Basepack::Import::Importable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/basepack/import/importable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #around_import(import, &block) ⇒ Object (also: #around_import!)
Class Method Details
.find_or_initialize_for_import(model, attrs, key = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/basepack/import/importable.rb', line 28 def self.find_or_initialize_for_import(model, attrs, key = nil) key ||= model.primary_key if attrs[key] object = model.where(key => attrs[key]).first_or_initialize object.assign_attributes(attrs.except(key)) object else model.new(attrs) end end |
Instance Method Details
#around_import(import, &block) ⇒ Object Also known as: around_import!
23 24 25 |
# File 'lib/basepack/import/importable.rb', line 23 def around_import(import, &block) yield end |