Sha256: 944ff244658f4ef8967e94d89075321ce2427bbf0fcbcda651b243282f3e0287

Contents?: true

Size: 389 Bytes

Versions: 3

Compression:

Stored size: 389 Bytes

Contents

module Dolly
  class PropertySet < Set
    def include? key
      keys.include?(key)
    end

    def <<(property)
      return if include?(property.key)
      super(property)
    end

    def [](key)
      return to_a[key] if key.is_a?(Integer)

      detect do |property|
        property.key == key.to_sym
      end
    end

    private

    def keys
      map(&:key)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dolly-3.1.5 lib/dolly/property_set.rb
dolly-3.1.4 lib/dolly/property_set.rb
dolly-3.1.3 lib/dolly/property_set.rb