Class: Frosting::Repository
- Inherits:
-
Object
- Object
- Frosting::Repository
show all
- Defined in:
- lib/frosting/repository.rb
Defined Under Namespace
Classes: PresenterMissingError
Class Method Summary
collapse
Class Method Details
.present(resource, options = {}) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/frosting/repository.rb', line 8
def self.present(resource, options = {})
klass = options.fetch(:presenter) { infer_presenter(resource) }
klass = procify(klass).call(resource)
klass.to_s.constantize.new(resource, options[:context])
rescue LoadError, NameError
raise PresenterMissingError.new("No such presenter: #{klass}")
end
|
.present_collection(collection, options = {}) ⇒ Object
16
17
18
|
# File 'lib/frosting/repository.rb', line 16
def self.present_collection(collection, options = {})
PresentedCollection.new(collection, options)
end
|