Class: CommandTower::UserAttributes::Mutate::Outcome
- Inherits:
-
Object
- Object
- CommandTower::UserAttributes::Mutate::Outcome
- Defined in:
- app/services/command_tower/user_attributes/mutate.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#invalid_argument_hash ⇒ Object
readonly
Returns the value of attribute invalid_argument_hash.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(success:, user:, attribute: nil, msg: nil, invalid_argument_hash: {}) ⇒ Outcome
constructor
A new instance of Outcome.
- #invalid_argument_keys ⇒ Object
- #invalid_arguments ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(success:, user:, attribute: nil, msg: nil, invalid_argument_hash: {}) ⇒ Outcome
Returns a new instance of Outcome.
29 30 31 32 33 34 35 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 29 def initialize(success:, user:, attribute: nil, msg: nil, invalid_argument_hash: {}) @success = success @user = user @attribute = attribute @msg = msg @invalid_argument_hash = invalid_argument_hash end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
16 17 18 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 16 def attribute @attribute end |
#invalid_argument_hash ⇒ Object (readonly)
Returns the value of attribute invalid_argument_hash.
16 17 18 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 16 def invalid_argument_hash @invalid_argument_hash end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
16 17 18 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 16 def msg @msg end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
16 17 18 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 16 def user @user end |
Class Method Details
.invalid(user:, errors:) ⇒ Object
22 23 24 25 26 27 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 22 def self.invalid(user:, errors:) invalid_argument_hash = errors.transform_values { { msg: _1 } } msg = "Invalid arguments: #{errors.map { |key, | "#{key}: #{}" }.join(", ")}" new(success: false, user:, msg:, invalid_argument_hash:) end |
.success(user:, attribute:) ⇒ Object
18 19 20 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 18 def self.success(user:, attribute:) new(success: true, user:, attribute:) end |
Instance Method Details
#failure? ⇒ Boolean
39 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 39 def failure? = !@success |
#invalid_argument_keys ⇒ Object
43 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 43 def invalid_argument_keys = invalid_argument_hash.keys |
#invalid_arguments ⇒ Object
41 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 41 def invalid_arguments = failure? |
#success? ⇒ Boolean
37 |
# File 'app/services/command_tower/user_attributes/mutate.rb', line 37 def success? = @success |