Class: ActsAsCalculator::ImportTemplate
- Inherits:
-
Object
- Object
- ActsAsCalculator::ImportTemplate
- Defined in:
- lib/acts_as_calculator/import_template.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
An import publishes.
-
#initialize(attributes:) ⇒ ImportTemplate
constructor
A new instance of ImportTemplate.
Constructor Details
#initialize(attributes:) ⇒ ImportTemplate
Returns a new instance of ImportTemplate.
9 10 11 12 13 14 |
# File 'lib/acts_as_calculator/import_template.rb', line 9 def initialize(attributes:) @attributes = attributes.transform_keys(&:to_s) @key = @attributes.fetch("key") { raise ImportError, "a templates entry has no key" }.to_s @scope = (@attributes["scope"] || DEFAULT_SCOPE).to_s @owner = ResolveImportOwner.(@attributes["owner"]) end |
Class Method Details
.call ⇒ Object
5 6 7 |
# File 'lib/acts_as_calculator/import_template.rb', line 5 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
An import publishes. The rake task's job is to make a deploy's templates the live
ones; a version that imported but stayed staged would look like it had worked and
render the previous body forever. Rollback stays PromoteTemplate.(template: older),
which the next import then reverses — the file is the source of truth.
20 21 22 23 24 |
# File 'lib/acts_as_calculator/import_template.rb', line 20 def call return outcome(:skipped, current) if current && current.body == body && current.format == format outcome(versions.exists? ? :updated : :created, publish) end |