Class: Ariadne::Yard::ComponentRef
- Inherits:
-
Object
- Object
- Ariadne::Yard::ComponentRef
- Defined in:
- lib/ariadne/yard/component_ref.rb
Overview
:nodoc:
Constant Summary collapse
- ATTR_DEFAULTS =
{ js: false, examples: 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
- #requires_js? ⇒ Boolean
- #should_have_examples? ⇒ Boolean
- #source_url ⇒ Object
Constructor Details
#initialize(klass, attrs) ⇒ ComponentRef
Returns a new instance of ComponentRef.
16 17 18 19 |
# File 'lib/ariadne/yard/component_ref.rb', line 16 def initialize(klass, attrs) @klass = klass @attrs = attrs end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
14 15 16 |
# File 'lib/ariadne/yard/component_ref.rb', line 14 def attrs @attrs end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
14 15 16 |
# File 'lib/ariadne/yard/component_ref.rb', line 14 def klass @klass end |
Instance Method Details
#form_component? ⇒ Boolean
29 30 31 |
# File 'lib/ariadne/yard/component_ref.rb', line 29 def form_component? @attrs.fetch(:form_component, ATTR_DEFAULTS[:form_component]) end |
#lookbook_url ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ariadne/yard/component_ref.rb', line 40 def lookbook_url @lookbook_url ||= begin path = klass.name.underscore.gsub("_component", "") "https://ariadne.style/view-components/lookbook/inspect/#{path}/default/" end end |
#requires_js? ⇒ Boolean
21 22 23 |
# File 'lib/ariadne/yard/component_ref.rb', line 21 def requires_js? @attrs.fetch(:js, ATTR_DEFAULTS[:js]) end |
#should_have_examples? ⇒ Boolean
25 26 27 |
# File 'lib/ariadne/yard/component_ref.rb', line 25 def should_have_examples? @attrs.fetch(:examples, ATTR_DEFAULTS[:examples]) end |
#source_url ⇒ Object
33 34 35 36 37 38 |
# File 'lib/ariadne/yard/component_ref.rb', line 33 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 |