Class: Hecks::Application::Commands::Create

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args:, repository:, domain_module:) ⇒ 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: )
  @repository      = repository
  @args            = args
  @errors          = {}
  @validator       = Hecks::Adapters::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

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

#resultObject



30
31
32
# File 'lib/commands/create.rb', line 30

def result
  { id: id, success: !id.nil?, errors: errors, args: args }
end

#to_hObject



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

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