Class: MoreViewHooks::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/more_view_hooks/hook.rb

Overview

Describes a preconfigured view hook which will be later applied by using the elegant Deface gem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hook_name, context, options) ⇒ Hook

Returns a new instance of Hook.



7
8
9
10
11
12
# File 'lib/more_view_hooks/hook.rb', line 7

def initialize(hook_name, context, options)
  @deface_options = options.merge(
    text: "<%= call_hook(:#{hook_name}, #{context || '{}'}) %>",
    name: "more_view_hooks_#{hook_name}"
  )
end

Instance Attribute Details

#deface_optionsObject (readonly)

Returns the value of attribute deface_options.



5
6
7
# File 'lib/more_view_hooks/hook.rb', line 5

def deface_options
  @deface_options
end

Instance Method Details

#apply!Object



14
15
16
# File 'lib/more_view_hooks/hook.rb', line 14

def apply!
  Deface::Override.new(deface_options)
end