Class: Pulitzer::PostTypesController::ImportVersion
- Inherits:
-
Object
- Object
- Pulitzer::PostTypesController::ImportVersion
- Defined in:
- app/interactions/pulitzer/post_types_controller/import_version.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(post_type, params) ⇒ ImportVersion
constructor
A new instance of ImportVersion.
Constructor Details
#initialize(post_type, params) ⇒ ImportVersion
Returns a new instance of ImportVersion.
3 4 5 6 7 |
# File 'app/interactions/pulitzer/post_types_controller/import_version.rb', line 3 def initialize(post_type, params) @post_type, @params = post_type, params last_version_number = @post_type.post_type_versions.maximum(:version_number) || 0 @this_version_number = last_version_number + 1 end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/interactions/pulitzer/post_types_controller/import_version.rb', line 9 def call import_json = @params[:import_json].read ptv = @post_type.post_type_versions.build ptv.from_json import_json ptv.version_number = @this_version_number ptv.status = 'incomplete' ptv.save ptv end |