Class: Attributor::Ids
- Inherits:
-
CSV
- Object
- Array
- Collection
- CSV
- Attributor::Ids
- Defined in:
- lib/attributor/types/ids.rb
Class Method Summary collapse
Methods inherited from CSV
decode_string, describe, dump, example, family
Methods inherited from Collection
check_option!, construct, constructable?, decode_string, describe, #dump, dump, example, family, inherited, load, member_attribute, member_type, native_type, valid_type?, validate, #validate, validate_options
Methods included from Dumpable
Methods included from Container
Class Method Details
.for(type) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/attributor/types/ids.rb', line 3 def self.for(type) identity_name = type..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) ⇒ Object
18 19 20 |
# 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 |