Class: GovFakeNotify::CreateTemplateCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/gov_fake_notify/commands/create_template_command.rb

Overview

A service used internally to create a new template from the API / command line

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, store: Store.instance) ⇒ CreateTemplateCommand

Returns a new instance of CreateTemplateCommand.



12
13
14
15
# File 'lib/gov_fake_notify/commands/create_template_command.rb', line 12

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

Class Method Details

.call(params) ⇒ Object



7
8
9
10
# File 'lib/gov_fake_notify/commands/create_template_command.rb', line 7

def self.call(params)
  # do nothing yet
  new(params).call
end

Instance Method Details

#callObject



17
18
19
20
21
# File 'lib/gov_fake_notify/commands/create_template_command.rb', line 17

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

  self
end

#success?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/gov_fake_notify/commands/create_template_command.rb', line 23

def success?
  true
end

#to_json(*_args) ⇒ Object



27
28
29
# File 'lib/gov_fake_notify/commands/create_template_command.rb', line 27

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