Class: Dato::Live
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Dato::Live
- Defined in:
- app/components/dato/live.rb
Instance Attribute Summary collapse
-
#component_klass ⇒ Object
readonly
Returns the value of attribute component_klass.
-
#live ⇒ Object
readonly
Returns the value of attribute live.
-
#preview ⇒ Object
readonly
Returns the value of attribute preview.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #cache_key ⇒ Object
- #data ⇒ Object
- #frame_id ⇒ Object
-
#initialize(component_klass, query, preview: false, live: false) ⇒ Live
constructor
A new instance of Live.
Constructor Details
#initialize(component_klass, query, preview: false, live: false) ⇒ Live
Returns a new instance of Live.
12 13 14 15 16 17 18 |
# File 'app/components/dato/live.rb', line 12 def initialize(component_klass, query, preview: false, live: false) super() @component_klass = component_klass @query = query @preview = preview @live = live end |
Instance Attribute Details
#component_klass ⇒ Object (readonly)
Returns the value of attribute component_klass.
10 11 12 |
# File 'app/components/dato/live.rb', line 10 def component_klass @component_klass end |
#live ⇒ Object (readonly)
Returns the value of attribute live.
10 11 12 |
# File 'app/components/dato/live.rb', line 10 def live @live end |
#preview ⇒ Object (readonly)
Returns the value of attribute preview.
10 11 12 |
# File 'app/components/dato/live.rb', line 10 def preview @preview end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
10 11 12 |
# File 'app/components/dato/live.rb', line 10 def query @query end |
Instance Method Details
#cache_key ⇒ Object
20 21 22 |
# File 'app/components/dato/live.rb', line 20 def cache_key @cache_key ||= Digest::MD5.hexdigest(query.to_gql) end |
#data ⇒ Object
24 25 26 |
# File 'app/components/dato/live.rb', line 24 def data @data ||= dato_fetch(query, preview: preview, live: live) end |
#frame_id ⇒ Object
28 29 30 |
# File 'app/components/dato/live.rb', line 28 def frame_id @frame_id ||= SecureRandom.hex(10) end |