Class: Decidim::ManifestMessages

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/lib/decidim/manifest_messages.rb

Instance Method Summary collapse

Constructor Details

#initializeManifestMessages

Returns a new instance of ManifestMessages.



5
6
7
# File 'decidim-core/lib/decidim/manifest_messages.rb', line 5

def initialize
  @store = {}
end

Instance Method Details

#has?(key) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'decidim-core/lib/decidim/manifest_messages.rb', line 9

def has?(key)
  @store.has_key?(key)
end

#render(key, context = nil, **extra) ⇒ Object



19
20
21
# File 'decidim-core/lib/decidim/manifest_messages.rb', line 19

def render(key, context = nil, **extra)
  context.instance_exec(**extra, &@store[key]) if @store[key]
end

#set(key, &block) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
# File 'decidim-core/lib/decidim/manifest_messages.rb', line 13

def set(key, &block)
  raise ArgumentError, "You need to provide a block for the message." unless block_given?

  @store[key] = block
end