Class: SleepingKingStudios::Tools::Messages::Strategies::HashStrategy

Inherits:
SleepingKingStudios::Tools::Messages::Strategy show all
Defined in:
lib/sleeping_king_studios/tools/messages/strategies/hash_strategy.rb

Overview

Messaging strategy that refers to an internal Hash of templates.

Direct Known Subclasses

Assertions::MessagesStrategy, FileStrategy

Defined Under Namespace

Classes: ParseError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SleepingKingStudios::Tools::Messages::Strategy

#call

Constructor Details

#initialize(templates) ⇒ HashStrategy

Returns a new instance of HashStrategy.

Parameters:

  • templates (Hash)

    the templates used to generate messages.



12
13
14
15
16
17
18
19
20
# File 'lib/sleeping_king_studios/tools/messages/strategies/hash_strategy.rb', line 12

def initialize(templates)
  super()

  unless templates.is_a?(Hash)
    raise ArgumentError, 'templates is not an instance of Hash'
  end

  @templates = flatten_templates(templates).freeze
end

Instance Attribute Details

#templatesHash (readonly)

Returns the templates used to generate messages.

Returns:

  • (Hash)

    the templates used to generate messages.



23
24
25
# File 'lib/sleeping_king_studios/tools/messages/strategies/hash_strategy.rb', line 23

def templates
  @templates
end