Class: Verto::DSL::Hook

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interpreter: DSL.interpreter, moment: :before, &block) ⇒ Hook

Returns a new instance of Hook.



8
9
10
11
12
# File 'lib/verto/dsl/hook.rb', line 8

def initialize(interpreter: DSL.interpreter, moment: :before, &block)
  @moment = moment.to_sym
  @interpreter = interpreter
  @block = block
end

Instance Attribute Details

#momentObject

Returns the value of attribute moment.



6
7
8
# File 'lib/verto/dsl/hook.rb', line 6

def moment
  @moment
end

Instance Method Details

#call(with_attributes: {}) ⇒ Object



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

def call(with_attributes: {})
  @interpreter.evaluate(attributes: with_attributes, &@block)
end