Sha256: 6678b5d118361b3d0b7a4eb459cda7ffb338ba0c021a3fdc21f7a8087b2ae75b

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

module Trailblazer::V2_1::Operation::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|
        method  = cfg[0]
        args    = cfg[1].dup
        block   = cfg[2]
        # options = args.extract_options!.dup # we need to duplicate options has as AM::Validations messes it up later.

        base.send(method, *args, &block) } # 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

1 entries across 1 versions & 1 rubygems

Version Path
trailblazer-future-2.1.0.rc1 lib/trailblazer/v2_1/operation/module.rb