Class: HaveAPI::ModelAdapters::ActiveRecord::Input

Inherits:
HaveAPI::ModelAdapter::Input show all
Defined in:
lib/haveapi/model_adapters/active_record.rb

Class Method Summary collapse

Methods inherited from HaveAPI::ModelAdapter::Input

#[], #has_param?, #initialize, used_by

Constructor Details

This class inherits a constructor from HaveAPI::ModelAdapter::Input

Class Method Details

.clean(model, raw, extra) ⇒ Object



144
145
146
147
148
149
150
151
152
# File 'lib/haveapi/model_adapters/active_record.rb', line 144

def self.clean(model, raw, extra)
  return if (raw.is_a?(String) && raw.empty?) || (!raw.is_a?(String) && !raw)

  if extra[:fetch]
    model.instance_exec(raw, &extra[:fetch])
  else
    model.find(raw)
  end
end