Class: AttributeExtras::HookBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/attribute_extras/hook_builder.rb

Overview

Builds a module that extends ActiveRecord::Base to build the macro corresponding to the given verb. For instance, for the verb :nullify, it will build a module that extends AR::Base with the method :nullify_attributes, which is then used to include the concern from the ExtraBuilder.

Instance Method Summary collapse

Constructor Details

#initialize(verb, past) ⇒ HookBuilder

store the given options



11
12
13
14
# File 'lib/attribute_extras/hook_builder.rb', line 11

def initialize(verb, past)
  @verb = verb
  @past = past
end

Instance Method Details

#buildObject

build the hook



17
18
19
20
21
# File 'lib/attribute_extras/hook_builder.rb', line 17

def build
  hook = Module.new
  hook.module_eval(module_definition)
  hook
end