Sha256: 2c80f92e24a4f3c2a81c4bde325fb09d049461f9fd86e2a0269c7f615374dab0

Contents?: true

Size: 567 Bytes

Versions: 7

Compression:

Stored size: 567 Bytes

Contents

module PR
  class DefineAndRegister

    class << self
      def [] klass, name, type, options = {}
        new(klass).define_and_register name, type, options
      end
    end

    def initialize klass
      @registry = FieldRegistry[klass]
      @klass = klass
    end

    def define_and_register name, type, options
      register name, define(name,type,options)
    end

    def register name, field
      @registry.register name, field
    end

    def define name, type, options = {}
      DefineField[ @klass, name, Fields[type], options ]
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pr-1.0.0 lib/pr/define_and_register.rb
pr-0.0.7 lib/pr/define_and_register.rb
pr-0.0.6 lib/pr/define_and_register.rb
pr-0.0.5 lib/pr/define_and_register.rb
pr-0.0.4 lib/pr/define_and_register.rb
pr-0.0.3 lib/pr/define_and_register.rb
pr-0.0.2 lib/pr/define_and_register.rb