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.
| 7 8 9 10 | # File 'lib/logux/class_finder.rb', line 7 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
| 30 31 32 33 34 35 36 | # File 'lib/logux/class_finder.rb', line 30 def class_name if subscribe? action.channel_name.camelize else action.type.split('/')[0..-2].map(&:camelize).join('::') end end | 
#find_action_class ⇒ Object
| 12 13 14 15 16 17 18 19 | # File 'lib/logux/class_finder.rb', line 12 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
| 21 22 23 24 25 26 27 28 | # File 'lib/logux/class_finder.rb', line 21 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 |