module Structural::Model::TypeCasts

Public Class Methods

cast(type, value) click to toggle source
# File lib/structural/model/type_casts.rb, line 5
def self.cast(type, value)
  if value.is_a?(type)
    value
  else
    casts.fetch(type, Identity).cast(value)
  end
end
register(cast) click to toggle source
# File lib/structural/model/type_casts.rb, line 13
def self.register(cast)
  casts[cast.type] = cast
end

Private Class Methods

casts() click to toggle source
# File lib/structural/model/type_casts.rb, line 19
def self.casts
  @casts ||= {}
end