class GovFakeNotify::FetchTemplatesCommand
A service used to fetch all templates
Attributes
errors[R]
params[R]
results[R]
store[R]
Public Class Methods
call(params, **kwargs)
click to toggle source
# File lib/gov_fake_notify/commands/fetch_templates_command.rb, line 13 def self.call(params, **kwargs) new(params, **kwargs).call end
new(params, store: Store.instance)
click to toggle source
# File lib/gov_fake_notify/commands/fetch_templates_command.rb, line 17 def initialize(params, store: Store.instance) @params = params @store = store @errors = [] @results = [] end
Public Instance Methods
call()
click to toggle source
# File lib/gov_fake_notify/commands/fetch_templates_command.rb, line 24 def call @results = store.transaction { store.roots.select { |k| k =~ /^template-/ } }.map do |key| store.transaction { store.fetch(key).slice('id', 'name', 'subject') } end self end
success?()
click to toggle source
# File lib/gov_fake_notify/commands/fetch_templates_command.rb, line 31 def success? errors.empty? end
to_json()
click to toggle source
# File lib/gov_fake_notify/commands/fetch_templates_command.rb, line 35 def to_json JSON.pretty_generate(templates: results) end