Class: HecksApplication::Commands::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/create.rb

Overview

Create a resource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args:, repository:, domain_module:, validator: HecksApplication::Validator) ⇒ Create

Returns a new instance of Create.



8
9
10
11
12
13
14
# File 'lib/commands/create.rb', line 8

def initialize(args:, repository:, domain_module:, validator: HecksApplication::Validator)
  @repository      = repository
  @args            = args
  @errors          = {}
  @validator       = validator
  @domain_module   = domain_module
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



6
7
8
# File 'lib/commands/create.rb', line 6

def args
  @args
end

#domain_moduleObject

Returns the value of attribute domain_module.



6
7
8
# File 'lib/commands/create.rb', line 6

def domain_module
  @domain_module
end

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/commands/create.rb', line 6

def errors
  @errors
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/commands/create.rb', line 6

def id
  @id
end

#repositoryObject

Returns the value of attribute repository.



6
7
8
# File 'lib/commands/create.rb', line 6

def repository
  @repository
end

#resultObject

Returns the value of attribute result.



6
7
8
# File 'lib/commands/create.rb', line 6

def result
  @result
end

Instance Method Details

#callObject



16
17
18
19
20
# File 'lib/commands/create.rb', line 16

def call
  validate
  create
  self
end

#nameObject



26
27
28
# File 'lib/commands/create.rb', line 26

def name
  self.class.to_s.split('::').last.underscore
end

#to_hObject



22
23
24
# File 'lib/commands/create.rb', line 22

def to_h
  { errors: errors, id: repository_result, args: args }
end