Class: Attributor::Ids
- Inherits:
-
CSV
show all
- Defined in:
- lib/attributor/types/ids.rb
Class Method Summary
collapse
Methods inherited from CSV
decode_string
Methods inherited from Collection
check_option!, construct, decode_string, describe, dump, example, load, member_attribute, member_type, native_type, validate, validate_options
Methods included from Container
included
Class Method Details
.for(type) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/attributor/types/ids.rb', line 6
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
|
22
23
24
|
# File 'lib/attributor/types/ids.rb', line 22
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
|