Class: ViewModel::ActiveRecord::Controller::ViewmodelIdSerializer

Inherits:
IknowParams::Serializer
  • Object
show all
Defined in:
lib/view_model/active_record/controller.rb

Overview

Viewmodel ids are permitted to be either integers or strings

Instance Method Summary collapse

Constructor Details

#initializeViewmodelIdSerializer

Returns a new instance of ViewmodelIdSerializer.



101
102
103
# File 'lib/view_model/active_record/controller.rb', line 101

def initialize
  super(::Object)
end

Instance Method Details

#load(val) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/view_model/active_record/controller.rb', line 105

def load(val)
  case val
  when ::Integer, ::String
    val
  else
    raise IknowParams::Serializer::LoadError.new(
            "Incorrect type for #{self.class.name}: #{val.inspect}:#{val.class.name}")
  end
end