Class: AttributeExtras::ExtraBuilder

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

Overview

Builds a concern that will be included into classes when they call the macro corresponding to the given verb. For instance, for the verb :nullify it will build out AttributeExtras::NullifyAttributes, which can be included into classes to get all of the utility functions.

Instance Method Summary collapse

Constructor Details

#initialize(verb, past, function, validator, options) ⇒ ExtraBuilder

store the given options



10
11
12
13
14
15
16
# File 'lib/attribute_extras/extra_builder.rb', line 10

def initialize(verb, past, function, validator, options)
  @verb = verb
  @past = past
  @function = function
  @validator = validator
  @options = options
end

Instance Method Details

#buildObject

build the extra



19
20
21
22
23
24
# File 'lib/attribute_extras/extra_builder.rb', line 19

def build
  concern = Module.new
  concern.module_eval(concern_definition)
  concern::ClassMethods.module_eval(&utilities_definition)
  concern
end