Class: Kozo::Types::Reference

Inherits:
Kozo::Type show all
Defined in:
lib/kozo/types/reference.rb

Class Method Summary collapse

Methods inherited from Kozo::Type

lookup

Class Method Details

.cast(value) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/kozo/types/reference.rb', line 6

def self.cast(value)
  return value if value.is_a? Kozo::Reference
  return unless value.is_a? Resource

  # TODO: infer configuration
  Kozo::Reference
    .new(resource_class: value.class, id: value.id)
    .send(value.state_name)
end