Sha256: e3a78c7bd5072f9b9b8d9156856bd712b8362cfc22cdc66c27a88ec903d73eda

Contents?: true

Size: 823 Bytes

Versions: 9

Compression:

Stored size: 823 Bytes

Contents

# Include this in every module that gets further included.
# TODO: this could be implemented in Declarable, as we can use that everywhere.
module Reform::Form::Module
  def self.included(base)
    base.extend ClassMethods
    base.extend Included
  end

  module Included # TODO: use representable's inheritance mechanism.
    def included(base)
      super
      instructions.each { |cfg|
        args    = cfg[1].dup
        options = args.extract_options!.dup # we need to duplicate options has as AM::Validations messes it up later.

        base.send(cfg[0], *args, options, &cfg[2]) } # property :name, {} do .. end
    end
  end

  module ClassMethods
    def method_missing(method, *args, &block)
      instructions << [method, args, block]
    end

    def instructions
      @instructions ||= []
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reform-2.0.5 lib/reform/form/module.rb
reform-2.0.4 lib/reform/form/module.rb
reform-2.0.3 lib/reform/form/module.rb
reform-2.0.2 lib/reform/form/module.rb
reform-2.0.1 lib/reform/form/module.rb
reform-2.0.0 lib/reform/form/module.rb
reform-2.0.0.rc3 lib/reform/form/module.rb
reform-2.0.0.rc2 lib/reform/form/module.rb
reform-2.0.0.rc1 lib/reform/form/module.rb