Class: Riddler::UseCases::ShowSlug
- Inherits:
-
Object
- Object
- Riddler::UseCases::ShowSlug
- Defined in:
- lib/riddler/use_cases/show_slug.rb
Instance Attribute Summary collapse
-
#content_definition_repo ⇒ Object
readonly
Returns the value of attribute content_definition_repo.
-
#context_director ⇒ Object
readonly
Returns the value of attribute context_director.
-
#interaction ⇒ Object
readonly
Returns the value of attribute interaction.
-
#interaction_class ⇒ Object
readonly
Returns the value of attribute interaction_class.
-
#interaction_repo ⇒ Object
readonly
Returns the value of attribute interaction_repo.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#slug_name ⇒ Object
readonly
Returns the value of attribute slug_name.
-
#slug_repo ⇒ Object
readonly
Returns the value of attribute slug_repo.
Instance Method Summary collapse
- #completed? ⇒ Boolean
- #dismissed? ⇒ Boolean
- #excluded? ⇒ Boolean
- #exists? ⇒ Boolean
-
#initialize(content_definition_repo:, slug_repo:, interaction_repo:, interaction_class:, slug_name:, params: {}, headers: {}) ⇒ ShowSlug
constructor
A new instance of ShowSlug.
- #paused? ⇒ Boolean
- #process ⇒ Object
- #targeted? ⇒ Boolean
Constructor Details
#initialize(content_definition_repo:, slug_repo:, interaction_repo:, interaction_class:, slug_name:, params: {}, headers: {}) ⇒ ShowSlug
Returns a new instance of ShowSlug.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/riddler/use_cases/show_slug.rb', line 7 def initialize content_definition_repo:, slug_repo:, interaction_repo:, interaction_class:, slug_name:, params: {}, headers: {} @content_definition_repo = content_definition_repo @slug_repo = slug_repo @interaction_repo = interaction_repo @interaction_class = interaction_class @context_director = ::Riddler::ContextDirector.new params: params, headers: headers @slug_name = slug_name @slug = lookup_slug end |
Instance Attribute Details
#content_definition_repo ⇒ Object (readonly)
Returns the value of attribute content_definition_repo.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def content_definition_repo @content_definition_repo end |
#context_director ⇒ Object (readonly)
Returns the value of attribute context_director.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def context_director @context_director end |
#interaction ⇒ Object (readonly)
Returns the value of attribute interaction.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def interaction @interaction end |
#interaction_class ⇒ Object (readonly)
Returns the value of attribute interaction_class.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def interaction_class @interaction_class end |
#interaction_repo ⇒ Object (readonly)
Returns the value of attribute interaction_repo.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def interaction_repo @interaction_repo end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def slug @slug end |
#slug_name ⇒ Object (readonly)
Returns the value of attribute slug_name.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def slug_name @slug_name end |
#slug_repo ⇒ Object (readonly)
Returns the value of attribute slug_repo.
4 5 6 |
# File 'lib/riddler/use_cases/show_slug.rb', line 4 def slug_repo @slug_repo end |
Instance Method Details
#completed? ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/riddler/use_cases/show_slug.rb', line 35 def completed? return false unless slug_defines_identity? find_interaction return false if @interaction.nil? @interaction.status == "COMPLETED" end |
#dismissed? ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/riddler/use_cases/show_slug.rb', line 28 def dismissed? return false unless slug_defines_identity? find_interaction return false if @interaction.nil? @interaction.status == "DISMISSED" end |
#excluded? ⇒ Boolean
46 47 48 |
# File 'lib/riddler/use_cases/show_slug.rb', line 46 def excluded? definition_use_case.excluded? end |
#exists? ⇒ Boolean
19 20 21 |
# File 'lib/riddler/use_cases/show_slug.rb', line 19 def exists? !slug.nil? end |
#paused? ⇒ Boolean
23 24 25 26 |
# File 'lib/riddler/use_cases/show_slug.rb', line 23 def paused? return true if slug.nil? slug.status == "PAUSED" end |
#process ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/riddler/use_cases/show_slug.rb', line 50 def process find_interaction || create_interaction context.assign "interaction", interaction.to_hash content_hash = definition_use_case.process.merge \ interaction_id: interaction.id, dismiss_url: "/interactions/#{interaction.id}/dismiss" interaction.content_type = content_hash[:content_type] interaction.content_id = content_hash[:id] interaction_repo.update interaction content_hash end |
#targeted? ⇒ Boolean
42 43 44 |
# File 'lib/riddler/use_cases/show_slug.rb', line 42 def targeted? slug_targeted? end |