Class: Logux::ClassFinder
- Inherits:
-
Object
- Object
- Logux::ClassFinder
- Defined in:
- lib/logux/class_finder.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #class_name ⇒ Object
- #find_action_class ⇒ Object
- #find_policy_class ⇒ Object
-
#initialize(action:, meta:) ⇒ ClassFinder
constructor
A new instance of ClassFinder.
Constructor Details
#initialize(action:, meta:) ⇒ ClassFinder
Returns a new instance of ClassFinder.
9 10 11 12 |
# File 'lib/logux/class_finder.rb', line 9 def initialize(action:, meta:) @action = action @meta = end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
5 6 7 |
# File 'lib/logux/class_finder.rb', line 5 def action @action end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
5 6 7 |
# File 'lib/logux/class_finder.rb', line 5 def @meta end |
Instance Method Details
#class_name ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/logux/class_finder.rb', line 32 def class_name if subscribe? action.channel_name.camelize else action.type.split('/')[0..-2].map(&:camelize).join('::') end end |
#find_action_class ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/logux/class_finder.rb', line 14 def find_action_class "#{class_namespace}::#{class_name}".constantize rescue NameError = "Unable to find action #{class_name.camelize}.\n" \ "Should be in app/logux/#{class_namespace.downcase}/#{class_path}.rb" raise_error_for_failed_find() end |
#find_policy_class ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/logux/class_finder.rb', line 23 def find_policy_class "Policies::#{class_namespace}::#{class_name}".constantize rescue NameError = "Unable to find action policy #{class_name.camelize}.\n" \ "Should be in app/logux/#{class_namespace.downcase}/#{class_path}.rb" raise_error_for_failed_find() end |