Class: Hybag::Ingester

Inherits:
Object
  • Object
show all
Defined in:
lib/hybag/ingester.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bag) ⇒ Ingester

Returns a new instance of Ingester.


6
7
8
# File 'lib/hybag/ingester.rb', line 6

def initialize(bag)
  @bag = bag
end

Instance Attribute Details

#bagObject

Returns the value of attribute bag


5
6
7
# File 'lib/hybag/ingester.rb', line 5

def bag
  @bag
end

#model_nameObject

Returns the value of attribute model_name


5
6
7
# File 'lib/hybag/ingester.rb', line 5

def model_name
  @model_name
end

#old_subjectObject

Returns the value of attribute old_subject


5
6
7
# File 'lib/hybag/ingester.rb', line 5

def old_subject
  @old_subject
end

Instance Method Details

#ingestObject


10
11
12
13
14
15
16
17
18
# File 'lib/hybag/ingester.rb', line 10

def ingest
  raise Hybag::UndiscoverableModelName.new(bag) if model_name.blank?
  new_object = model_name.constantize.new
  # Assign a pid
  new_object.inner_object.pid = new_object.inner_object.assign_pid
  (new_object)
  set_file_streams(new_object)
  return new_object
end