Module: GuardRail::HelperMethods::ClassMethods

Defined in:
lib/guard_rail/helper_methods.rb

Overview

see readme for example usage

Instance Method Summary collapse

Instance Method Details

#guard_rail_class_method(method, opts) ⇒ Object



15
16
17
# File 'lib/guard_rail/helper_methods.rb', line 15

def guard_rail_class_method(method, opts)
  self.singleton_class.guard_rail_method(method, opts)
end

#guard_rail_class_methods(*methods, opts) ⇒ Object



11
12
13
# File 'lib/guard_rail/helper_methods.rb', line 11

def guard_rail_class_methods(*methods, opts)
  methods.each { |m| guard_rail_class_method(m, opts) }
end

#guard_rail_method(method, opts) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/guard_rail/helper_methods.rb', line 23

def guard_rail_method(method, opts)
  @guard_rail_module ||= begin
    m = Module.new
    self.prepend m
    m
  end

  @guard_rail_module.class_eval "   def \#{method}(*args)\n     GuardRail.activate(\#{opts[:environment].inspect}) { super }\n   end\n  RUBY\nend\n", __FILE__, __LINE__ + 1

#guard_rail_methods(*methods, opts) ⇒ Object



19
20
21
# File 'lib/guard_rail/helper_methods.rb', line 19

def guard_rail_methods(*methods, opts)
  methods.each { |m| guard_rail_method(m, opts) }
end