Sha256: 341a137c622729286f71928bfec57d3eddda11f80453a67ed8895a5e08f0a3ea

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

# Include this in every module that gets further included.
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| base.send(cfg[0], *cfg[1], &cfg[2]) } # property :name, {} do .. end
    end
  end

  module ClassMethods
    def property(*args, &block)
      instructions << [:property, args, block]
    end
    def validates(*args, &block)
      instructions << [:validates, args, block]
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reform-1.1.0 lib/reform/form/module.rb