class Trestle::Hook

Attributes

block[R]
name[R]
options[R]

Public Class Methods

new(name, options={}, &block) click to toggle source
# File lib/trestle/hook.rb, line 8
def initialize(name, options={}, &block)
  @name, @options, @block = name, options, block
end

Public Instance Methods

==(other) click to toggle source
# File lib/trestle/hook.rb, line 12
def ==(other)
  other.is_a?(self.class) && name == other.name && options == other.options && block == other.block
end
evaluate(context, *args) click to toggle source
# File lib/trestle/hook.rb, line 26
def evaluate(context, *args)
  context.instance_exec(*args, &block)
end
visible?(context) click to toggle source
# File lib/trestle/hook.rb, line 16
def visible?(context)
  if options[:if]
    context.instance_exec(&options[:if])
  elsif options[:unless]
    !context.instance_exec(&options[:unless])
  else
    true
  end
end