Sha256: 7a53ee7a348b647f659048c71138dcc57c5d2de9d8e41b7b5eae3134642ecdfd

Contents?: true

Size: 417 Bytes

Versions: 7

Compression:

Stored size: 417 Bytes

Contents

module PR
  class FieldRegistry

    def self.[] klass
      @registers ||= {}
      @registers[klass] ||= new(klass)
    end

    def initialize klass
      @for = klass
      @fields = {}
    end
    attr_reader :for

    def register field_name, field
      @fields[field_name] = field
    end

    def fetch field_name
      @fields.fetch field_name
    end

    def fields
      @fields.keys
    end


  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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