Class: ApiMaker::CommandService
- Inherits:
-
ApplicationService
- Object
- ServicePattern::Service
- ApplicationService
- ApiMaker::CommandService
- Defined in:
- app/services/api_maker/command_service.rb
Direct Known Subclasses
CollectionCommandService, CreateCommandService, DestroyCommandService, IndexCommandService, MemberCommandService, ServiceCommandService, UpdateCommandService, ValidCommandService
Instance Attribute Summary collapse
-
#ability ⇒ Object
readonly
Returns the value of attribute ability.
-
#api_maker_args ⇒ Object
readonly
Returns the value of attribute api_maker_args.
-
#command_name ⇒ Object
readonly
Returns the value of attribute command_name.
-
#command_response ⇒ Object
readonly
Returns the value of attribute command_response.
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#resource_name ⇒ Object
readonly
Returns the value of attribute resource_name.
Instance Method Summary collapse
-
#initialize(ability:, api_maker_args:, commands:, command_name:, command_response:, controller:, resource_name:) ⇒ CommandService
constructor
A new instance of CommandService.
- #model_class ⇒ Object
- #namespace ⇒ Object
- #resource ⇒ Object
Methods inherited from ApplicationService
Constructor Details
#initialize(ability:, api_maker_args:, commands:, command_name:, command_response:, controller:, resource_name:) ⇒ CommandService
Returns a new instance of CommandService.
4 5 6 7 8 9 10 11 12 |
# File 'app/services/api_maker/command_service.rb', line 4 def initialize(ability:, api_maker_args:, commands:, command_name:, command_response:, controller:, resource_name:) @ability = ability @api_maker_args = api_maker_args @command_name = command_name @command_response = command_response @commands = commands @controller = controller @resource_name = resource_name end |
Instance Attribute Details
#ability ⇒ Object (readonly)
Returns the value of attribute ability.
2 3 4 |
# File 'app/services/api_maker/command_service.rb', line 2 def ability @ability end |
#api_maker_args ⇒ Object (readonly)
Returns the value of attribute api_maker_args.
2 3 4 |
# File 'app/services/api_maker/command_service.rb', line 2 def api_maker_args @api_maker_args end |
#command_name ⇒ Object (readonly)
Returns the value of attribute command_name.
2 3 4 |
# File 'app/services/api_maker/command_service.rb', line 2 def command_name @command_name end |
#command_response ⇒ Object (readonly)
Returns the value of attribute command_response.
2 3 4 |
# File 'app/services/api_maker/command_service.rb', line 2 def command_response @command_response end |
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
2 3 4 |
# File 'app/services/api_maker/command_service.rb', line 2 def commands @commands end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
2 3 4 |
# File 'app/services/api_maker/command_service.rb', line 2 def controller @controller end |
#resource_name ⇒ Object (readonly)
Returns the value of attribute resource_name.
2 3 4 |
# File 'app/services/api_maker/command_service.rb', line 2 def resource_name @resource_name end |
Instance Method Details
#model_class ⇒ Object
28 29 30 |
# File 'app/services/api_maker/command_service.rb', line 28 def model_class @model_class ||= resource.model_class end |
#namespace ⇒ Object
14 15 16 |
# File 'app/services/api_maker/command_service.rb', line 14 def namespace @namespace ||= resource_name.underscore.camelize end |
#resource ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/services/api_maker/command_service.rb', line 18 def resource @resource ||= begin resource_class_name = "Resources::#{resource_name.underscore.singularize.camelize}Resource" resource = resource_class_name.safe_constantize raise "Couldnt find resource from resource name: #{resource_class_name}" unless resource resource end end |