class AttributeExtras::AttributeExtra

Parent class of the various extras.

Attributes

name[R]

Public Class Methods

new(name, attributes, perform) click to toggle source
# File lib/attribute_extras.rb, line 11
def initialize(name, attributes, perform)
  @name = name
  define_extra(name, attributes, perform)
end

Public Instance Methods

included(clazz) click to toggle source
# File lib/attribute_extras.rb, line 16
def included(clazz)
  clazz.before_validation(name)
end

Private Instance Methods

define_extra(name, attributes, perform) click to toggle source
# File lib/attribute_extras.rb, line 22
def define_extra(name, attributes, perform)
  define_method(name) do
    attributes.each do |attribute|
      value = public_send(attribute)
      public_send(:"#{attribute}=", perform[self, attribute, value])
    end
  end
end