Class: HecksApplication::Commands::CRUDHandler
- Inherits:
-
Object
- Object
- HecksApplication::Commands::CRUDHandler
- Defined in:
- lib/commands/crud_handler.rb
Overview
Map resourceful methods to the domain
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Instance Method Summary collapse
- #create(args) ⇒ Object
- #delete(id) ⇒ Object
-
#initialize(module_name:, application:, validator:) ⇒ CRUDHandler
constructor
A new instance of CRUDHandler.
- #read(id) ⇒ Object
- #update(attributes) ⇒ Object
Constructor Details
#initialize(module_name:, application:, validator:) ⇒ CRUDHandler
Returns a new instance of CRUDHandler.
7 8 9 10 11 |
# File 'lib/commands/crud_handler.rb', line 7 def initialize(module_name:, application:, validator:) @module_name = module_name @application = application @validator = validator end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
5 6 7 |
# File 'lib/commands/crud_handler.rb', line 5 def application @application end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
5 6 7 |
# File 'lib/commands/crud_handler.rb', line 5 def module_name @module_name end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
5 6 7 |
# File 'lib/commands/crud_handler.rb', line 5 def validator @validator end |
Instance Method Details
#create(args) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/commands/crud_handler.rb', line 13 def create(args) application.call( module_name: module_name, command_name: :create, args: args ) end |
#delete(id) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/commands/crud_handler.rb', line 37 def delete(id) application.call( module_name: module_name, command_name: :delete, args: { id: id } ) end |
#read(id) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/commands/crud_handler.rb', line 21 def read(id) application.query( module_name: module_name, query_name: :find_by_id, args: { id: id } ) end |
#update(attributes) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/commands/crud_handler.rb', line 29 def update(attributes) application.call( module_name: module_name, command_name: :update, args: attributes ) end |