Class: Dato::Live

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/dato/live.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_klassObject (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

#liveObject (readonly)

Returns the value of attribute live.



10
11
12
# File 'app/components/dato/live.rb', line 10

def live
  @live
end

#previewObject (readonly)

Returns the value of attribute preview.



10
11
12
# File 'app/components/dato/live.rb', line 10

def preview
  @preview
end

#queryObject (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_keyObject



20
21
22
# File 'app/components/dato/live.rb', line 20

def cache_key
  @cache_key ||= Digest::MD5.hexdigest(query.to_gql)
end

#dataObject



24
25
26
# File 'app/components/dato/live.rb', line 24

def data
  @data ||= dato_fetch(query, preview: preview, live: live)
end

#frame_idObject



28
29
30
# File 'app/components/dato/live.rb', line 28

def frame_id
  @frame_id ||= SecureRandom.hex(10)
end