Sha256: 5afceab9054d1f04bd499cf2c13581dd4191c7c565c736135982a57e4743bd82

Contents?: true

Size: 424 Bytes

Versions: 3

Compression:

Stored size: 424 Bytes

Contents

require 'rom/support/registry'
require 'rom/support/inflector'

module ROM
  class AssociationSet < ROM::Registry
    # @api private
    def try(name, &block)
      if key?(name)
        yield(self[name])
      else
        false
      end
    end

    # @api private
    def [](name)
      key = name.to_sym

      if key?(key)
        super
      else
        super(Inflector.singularize(key))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-2.0.2 lib/rom/association_set.rb
rom-2.0.1 lib/rom/association_set.rb
rom-2.0.0 lib/rom/association_set.rb