Class: Graphiti::OpenAPI::Resources

Inherits:
Hash
  • Object
show all
Defined in:
app/models/graphiti/open_api/resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(schema, data = ) ⇒ Object

Parameters:



328
329
330
331
332
# File 'app/models/graphiti/open_api/resource.rb', line 328

def self.load(schema, data = schema.__attributes__[:resources])
  data.each_with_object(new) do |resource, result|
    result[resource.name] = Resource.new(resource.to_hash.merge(schema: schema))
  end
end

Instance Method Details

#by_model(model) ⇒ Object



334
335
336
# File 'app/models/graphiti/open_api/resource.rb', line 334

def by_model(model)
  fetch("#{model}Resource")
end

#by_type(type) ⇒ Object



338
339
340
# File 'app/models/graphiti/open_api/resource.rb', line 338

def by_type(type)
  values.detect { |resource| resource.type = type }
end