Class: Brainstem::ApiDocs::PresenterCollection
- Inherits:
- 
      AbstractCollection
      
        - Object
- AbstractCollection
- Brainstem::ApiDocs::PresenterCollection
 
- Includes:
- Concerns::Formattable
- Defined in:
- lib/brainstem/api_docs/presenter_collection.rb
Instance Attribute Summary collapse
- 
  
    
      #presenter_constant_lookup_method  ⇒ Object 
    
    
  
  
  
  
    
    
      writeonly
    
  
  
  
  
  
  
    Sets the attribute presenter_constant_lookup_method. 
Attributes included from Concerns::Formattable
Attributes inherited from AbstractCollection
Instance Method Summary collapse
- #create_from_presenter_collection(target_class, const) ⇒ Object
- 
  
    
      #create_from_target_class(target_class)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Creates a new Presenterwrapper and appends it to the collection.
- 
  
    
      #find_by_target_class(target_class)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Finds a presenter for the given class. 
- #find_or_create_from_presenter_collection(target_class, const) ⇒ Object (also: #find_or_create_by_presenter_collection)
- 
  
    
      #find_or_create_from_target_class(target_class)  ⇒ Object 
    
    
      (also: #find_or_create_by_target_class)
    
  
  
  
  
  
  
  
  
  
    Finds or creates a presenter with the given target class and appends it to the members list if it is new. 
- #valid_options ⇒ Object
Methods included from Concerns::Formattable
#formatted_as, #formatter_type
Methods inherited from AbstractCollection
#<<, #each, #each_filename, #each_formatted, #each_formatted_with_filename, #filenames, #formatted, #formatted_with_filename, #initialize, #last, with_members
Methods included from Concerns::Optional
Constructor Details
This class inherits a constructor from Brainstem::ApiDocs::AbstractCollection
Instance Attribute Details
#presenter_constant_lookup_method=(value) ⇒ Object
Sets the attribute presenter_constant_lookup_method
| 16 17 18 | # File 'lib/brainstem/api_docs/presenter_collection.rb', line 16 def presenter_constant_lookup_method=(value) @presenter_constant_lookup_method = value end | 
Instance Method Details
#create_from_presenter_collection(target_class, const) ⇒ Object
| 61 62 63 64 65 66 | # File 'lib/brainstem/api_docs/presenter_collection.rb', line 61 def create_from_presenter_collection(target_class, const) ::Brainstem::ApiDocs::Presenter.new(atlas, target_class: target_class, const: const ).tap { |p| self.<< p } end | 
#create_from_target_class(target_class) ⇒ Object
Creates a new Presenter wrapper and appends it to the collection. If the constant lookup for the actual presenter class fails, returns nil.
| 43 44 45 46 47 48 49 50 | # File 'lib/brainstem/api_docs/presenter_collection.rb', line 43 def create_from_target_class(target_class) ::Brainstem::ApiDocs::Presenter.new(atlas, target_class: target_class, const: target_class_to_const(target_class) ).tap { |p| self.<< p } rescue KeyError nil end | 
#find_by_target_class(target_class) ⇒ Object
Finds a presenter for the given class
| 34 35 36 | # File 'lib/brainstem/api_docs/presenter_collection.rb', line 34 def find_by_target_class(target_class) find { |p| p.target_class == target_class } end | 
#find_or_create_from_presenter_collection(target_class, const) ⇒ Object Also known as: find_or_create_by_presenter_collection
| 53 54 55 56 | # File 'lib/brainstem/api_docs/presenter_collection.rb', line 53 def find_or_create_from_presenter_collection(target_class, const) find_by_target_class(target_class) || create_from_presenter_collection(target_class, const) end | 
#find_or_create_from_target_class(target_class) ⇒ Object Also known as: find_or_create_by_target_class
Finds or creates a presenter with the given target class and appends it to the members list if it is new.
| 23 24 25 26 | # File 'lib/brainstem/api_docs/presenter_collection.rb', line 23 def find_or_create_from_target_class(target_class) find_by_target_class(target_class) || create_from_target_class(target_class) end | 
#valid_options ⇒ Object
| 12 13 14 | # File 'lib/brainstem/api_docs/presenter_collection.rb', line 12 def super | [ :presenter_constant_lookup_method ] end |