Class: ModelExplorer::Import
- Inherits:
-
Object
- Object
- ModelExplorer::Import
- Defined in:
- lib/model_explorer/import.rb
Constant Summary collapse
- FAKE_PASSWORD =
"FakePa$$word12345!"
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#record_data ⇒ Object
readonly
Returns the value of attribute record_data.
Instance Method Summary collapse
- #import ⇒ ActiveRecord::Base
-
#initialize(record_data) ⇒ Import
constructor
A new instance of Import.
Constructor Details
#initialize(record_data) ⇒ Import
Returns a new instance of Import.
10 11 12 13 14 |
# File 'lib/model_explorer/import.rb', line 10 def initialize(record_data) @record_data = record_data @record = nil @model = nil end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/model_explorer/import.rb', line 7 def model @model end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
6 7 8 |
# File 'lib/model_explorer/import.rb', line 6 def record @record end |
#record_data ⇒ Object (readonly)
Returns the value of attribute record_data.
5 6 7 |
# File 'lib/model_explorer/import.rb', line 5 def record_data @record_data end |
Instance Method Details
#import ⇒ ActiveRecord::Base
17 18 19 20 21 22 23 24 |
# File 'lib/model_explorer/import.rb', line 17 def import @model = record_data[:model].constantize @record = model.find_or_initialize_by(record_data[:attributes]) create_record_with_associations! record end |