Class: Primer::Yard::ComponentRef
- Inherits:
 - 
      Object
      
        
- Object
 - Primer::Yard::ComponentRef
 
 
- Defined in:
 - lib/primer/yard/component_ref.rb
 
Overview
:nodoc:
Constant Summary collapse
- ATTR_DEFAULTS =
 { js: false, examples: true, published: true, form_component: false }.freeze
Instance Attribute Summary collapse
- 
  
    
      #attrs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute attrs.
 - 
  
    
      #klass  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute klass.
 
Instance Method Summary collapse
- #form_component? ⇒ Boolean
 - 
  
    
      #initialize(klass, attrs)  ⇒ ComponentRef 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ComponentRef.
 - #lookbook_url ⇒ Object
 - #published? ⇒ Boolean
 - #requires_js? ⇒ Boolean
 - #should_have_examples? ⇒ Boolean
 - #source_url ⇒ Object
 
Constructor Details
#initialize(klass, attrs) ⇒ ComponentRef
Returns a new instance of ComponentRef.
      17 18 19 20  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 17 def initialize(klass, attrs) @klass = klass @attrs = attrs end  | 
  
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
      15 16 17  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 15 def attrs @attrs end  | 
  
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
      15 16 17  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 15 def klass @klass end  | 
  
Instance Method Details
#form_component? ⇒ Boolean
      34 35 36  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 34 def form_component? @attrs.fetch(:form_component, ATTR_DEFAULTS[:form_component]) end  | 
  
#lookbook_url ⇒ Object
      45 46 47 48 49 50  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 45 def lookbook_url @lookbook_url ||= begin path = klass.name.underscore.gsub("_component", "") "https://primer.style/view-components/lookbook/inspect/#{path}/default/" end end  | 
  
#published? ⇒ Boolean
      30 31 32  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 30 def published? @attrs.fetch(:published, ATTR_DEFAULTS[:published]) end  | 
  
#requires_js? ⇒ Boolean
      22 23 24  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 22 def requires_js? @attrs.fetch(:js, ATTR_DEFAULTS[:js]) end  | 
  
#should_have_examples? ⇒ Boolean
      26 27 28  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 26 def should_have_examples? @attrs.fetch(:examples, ATTR_DEFAULTS[:examples]) end  | 
  
#source_url ⇒ Object
      38 39 40 41 42 43  | 
    
      # File 'lib/primer/yard/component_ref.rb', line 38 def source_url @source_url ||= begin path = klass.name.split("::").map(&:underscore).join("/") "https://github.com/primer/view_components/tree/main/app/components/#{path}.rb" end end  |