Class: Jahuty::Resource::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/jahuty/resource/factory.rb

Overview

Instantiates and returns a resource.

Constant Summary collapse

CLASSES =
{
  problem: Problem.name,
  render: Render.name
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(resource_name, payload) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# File 'lib/jahuty/resource/factory.rb', line 12

def call(resource_name, payload)
  klass = class_name(resource_name.to_sym)

  raise ArgumentError, "#{resource_name} missing" if klass.nil?

  Object.const_get(klass).send(:from, **payload)
end