Class: Logux::Action
- Inherits:
-
Object
- Object
- Logux::Action
- Extended by:
- Forwardable
- Defined in:
- lib/logux/action.rb
Direct Known Subclasses
Instance Method Summary collapse
- #[](key) ⇒ Object
- #action_name ⇒ Object
- #action_type ⇒ Object
- #channel ⇒ Object
- #channel_id ⇒ Object
- #channel_name ⇒ Object
- #fetch(key) ⇒ Object
-
#initialize(parameters = {}) ⇒ Action
constructor
A new instance of Action.
- #type ⇒ Object
Constructor Details
#initialize(parameters = {}) ⇒ Action
Returns a new instance of Action.
23 24 25 26 27 |
# File 'lib/logux/action.rb', line 23 def initialize(parameters = {}) raise ArgumentError, :parameters unless parameters.is_a?(Hash) @parameters = parameters.transform_keys(&:to_s) end |
Instance Method Details
#[](key) ⇒ Object
60 61 62 |
# File 'lib/logux/action.rb', line 60 def [](key) parameters[key.is_a?(Symbol) ? key.to_s : key] end |
#action_name ⇒ Object
29 30 31 |
# File 'lib/logux/action.rb', line 29 def action_name type&.split('/')&.dig(0) end |
#action_type ⇒ Object
33 34 35 |
# File 'lib/logux/action.rb', line 33 def action_type type&.split('/')&.last end |
#channel ⇒ Object
49 50 51 |
# File 'lib/logux/action.rb', line 49 def channel fetch('channel') end |
#channel_id ⇒ Object
41 42 43 |
# File 'lib/logux/action.rb', line 41 def channel_id channel&.split('/')&.last end |
#channel_name ⇒ Object
37 38 39 |
# File 'lib/logux/action.rb', line 37 def channel_name channel&.split('/')&.dig(0) end |
#fetch(key) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/logux/action.rb', line 53 def fetch(key) value = self[key] raise ParameterMissingError, key if value.to_s.empty? value end |
#type ⇒ Object
45 46 47 |
# File 'lib/logux/action.rb', line 45 def type fetch('type') end |