class Attributor::Ids

Public Class Methods

for(type) click to toggle source
# File lib/attributor/types/ids.rb, line 3
def self.for(type)
  identity_name = type.options.fetch(:identity) do
    raise AttributorException, "no identity found for #{type.name}"
  end

  identity_attribute = type.attributes.fetch(identity_name) do
    raise AttributorException, "#{type.name} does not have attribute with name '#{identity_name}'"
  end

  ::Class.new(self) do
    @member_attribute = identity_attribute
    @member_type = identity_attribute.type
  end
end
of(_type) click to toggle source
# File lib/attributor/types/ids.rb, line 18
def self.of(_type)
  raise 'Invalid definition of Ids type. Defining Ids.of(type) is not allowed, you probably meant to do Ids.for(type) instead'
end