Class: Decidim::ViewHooks::ViewHook

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

Overview

Internal class to encapsulate each view registered on a view hook.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(priority, block) ⇒ ViewHook

priority - a Number (Integer|Float) to sort the block. block - a block that will bbe rendered in a view context.


91
92
93
94
# File 'decidim-core/lib/decidim/view_hooks.rb', line 91

def initialize(priority, block)
  @priority = priority
  @block = block
end

Instance Attribute Details

#priorityObject (readonly)

Returns the value of attribute priority


96
97
98
# File 'decidim-core/lib/decidim/view_hooks.rb', line 96

def priority
  @priority
end

Instance Method Details

#render(view_context) ⇒ Object

Public: renders the block inside the view context.

view_context - a context to render the view hook.

Returns a String.


103
104
105
# File 'decidim-core/lib/decidim/view_hooks.rb', line 103

def render(view_context)
  @block.call(view_context)
end