Class: Azeroth::ResourceBuilder Private
- Inherits:
-
Sinclair::Model
- Object
- Sinclair::Model
- Azeroth::ResourceBuilder
- Defined in:
- lib/azeroth/resource_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Builder responsible for for building the resource methods
The builder adds 2 methods, one for listing all entries of a resource, and one for fetching an specific entry
Instance Method Summary collapse
-
#add_method ⇒ Array<Sinclair::MethodDefinition>
private
Add a method to be build on the controller.
-
#append ⇒ Array<Sinclair::MethodDefinition>
private
Append methods to be built to the builder.
-
#builder ⇒ Sinclair
private
Returns a method builder.
- #initialize(model: , builder: ) ⇒ ResourceBuilder constructor private
-
#model ⇒ Model
private
Returns the model class of the resource.
-
#name ⇒ String
private
Returns the name of the resource represented by the model.
-
#plural ⇒ String
private
Return the pluralized version of resource name.
Constructor Details
#initialize(model: , builder: ) ⇒ ResourceBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 |
# File 'lib/azeroth/resource_builder.rb', line 20 initialize_with(:model, :builder, writter: false) |
Instance Method Details
#add_method ⇒ Array<Sinclair::MethodDefinition>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add a method to be build on the controller
59 |
# File 'lib/azeroth/resource_builder.rb', line 59 delegate :name, :plural, to: :model |
#append ⇒ Array<Sinclair::MethodDefinition>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Append methods to be built to the builder
Methods are the listing of all entities and fetching of an specific entity
28 29 30 31 |
# File 'lib/azeroth/resource_builder.rb', line 28 def append add_method(plural, "@#{plural} ||= #{model.klass}.all") add_method(name, "@#{name} ||= #{plural}.find(#{name}_id)") end |
#builder ⇒ Sinclair
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a method builder
51 |
# File 'lib/azeroth/resource_builder.rb', line 51 delegate :add_method, to: :builder |
#model ⇒ Model
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the model class of the resource
|
# File 'lib/azeroth/resource_builder.rb', line 33
|
#name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the name of the resource represented by the model
|
# File 'lib/azeroth/resource_builder.rb', line 60
|
#plural ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the pluralized version of resource name
|
# File 'lib/azeroth/resource_builder.rb', line 67
|