Module: ControllerCommands::Command

Defined in:
lib/controller_commands/command.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



34
35
36
# File 'lib/controller_commands/command.rb', line 34

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#errorsObject



47
48
49
# File 'lib/controller_commands/command.rb', line 47

def errors
  @result.messages
end

#initialize(incoming_params, context) ⇒ Object



38
39
40
41
# File 'lib/controller_commands/command.rb', line 38

def initialize(incoming_params, context)
  @incoming_params = incoming_params
  @context = context
end

#performObject



64
65
66
# File 'lib/controller_commands/command.rb', line 64

def perform
  self.class.perform(@context, validated_params)
end

#success_messageObject



60
61
62
# File 'lib/controller_commands/command.rb', line 60

def success_message
  self.class.get_success_message
end

#validate_paramsObject



55
56
57
58
# File 'lib/controller_commands/command.rb', line 55

def validate_params
  @result = self.class.validate(@context, @incoming_params)
  @result.messages.count == 0
end

#validated?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/controller_commands/command.rb', line 43

def validated?
  !!@result
end

#validated_paramsObject



51
52
53
# File 'lib/controller_commands/command.rb', line 51

def validated_params
  @result.output
end