Sha256: 01472299afc8b4b7131b88696337cd2ae4d3eb723c3b73481811ec0a10fe2d4d

Contents?: true

Size: 650 Bytes

Versions: 5

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

require 'gov_fake_notify/store'
module GovFakeNotify
  # A service used internally to create a new template from the API / command line
  class CreateTemplateCommand
    def self.call(params)
      # do nothing yet
      new(params).call
    end

    def initialize(params, store: Store.instance)
      @params = params
      @store = store
    end

    def call
      store.transaction { store["template-#{params['id']}"] = params }

      self
    end

    def success?
      true
    end

    def to_json(*_args)
      JSON.generate({ success: true })
    end

    private

    attr_reader :params, :store
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gov_fake_notify-2.0.0 lib/gov_fake_notify/commands/create_template_command.rb
gov_fake_notify-1.2.0 lib/gov_fake_notify/commands/create_template_command.rb
gov_fake_notify-1.1.3 lib/gov_fake_notify/commands/create_template_command.rb
gov_fake_notify-1.1.2 lib/gov_fake_notify/commands/create_template_command.rb
gov_fake_notify-1.1.1 lib/gov_fake_notify/commands/create_template_command.rb