Module: Journeyviz

Defined in:
lib/journeyviz.rb,
lib/journeyviz/block.rb,
lib/journeyviz/action.rb,
lib/journeyviz/screen.rb,
lib/journeyviz/server.rb,
lib/journeyviz/journey.rb,
lib/journeyviz/version.rb,
lib/journeyviz/scopable.rb,
lib/journeyviz/graphable.rb,
lib/journeyviz/node_group.rb,
lib/journeyviz/normalized_name.rb,
lib/journeyviz/graphable/externals.rb,
lib/journeyviz/graphable/transitions.rb

Defined Under Namespace

Modules: Graphable, NodeGroup, NormalizedName Classes: Action, Block, DuplicatedDefinition, Error, InvalidNameError, InvalidTransition, Journey, Screen, Server

Constant Summary collapse

VERSION =
'0.2.1'
Scopable =
proc do |qualified_by|
  Module.new do
    attr_reader :scope

    def assign_scope(scope)
      @scope = scope
    end

    def root_scope
      current_scope = self
      current_scope = current_scope.scope until !current_scope.respond_to?(:scope) || current_scope.scope.nil?
      current_scope
    end

    def full_scope
      current_scope = scope
      chain = [current_scope]

      until current_scope.nil? || !current_scope.respond_to?(:scope)
        current_scope = current_scope.scope
        chain.unshift(current_scope)
      end

      chain
    end

    define_method(:full_qualifier) do
      base_qualifier = scope&.respond_to?(:full_qualifier) ? scope.full_qualifier : []
      [*base_qualifier, send(qualified_by)].compact
    end
  end
end

Class Method Summary collapse

Class Method Details

.act(action) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/journeyviz.rb', line 32

def act(action)
  # TODO
  # :action/day/:day ++
  # :action/week/:week ++
  # :action/month/:month ++
  # :action/quarter/:quarter ++
end

.configure(&block) ⇒ Object



14
15
16
17
18
# File 'lib/journeyviz.rb', line 14

def configure(&block)
  @journey = Journey.new
  block.call(journey)
  journey.validate!
end

.contextObject



40
41
42
# File 'lib/journeyviz.rb', line 40

def context
  Thread.current[:journeyviz_context] ||= {}
end

.identify(user_id) ⇒ Object



20
21
22
# File 'lib/journeyviz.rb', line 20

def identify(user_id)
  context[:user_id] = user_id
end

.journeyObject



44
45
46
# File 'lib/journeyviz.rb', line 44

def journey
  @journey ||= Journey.new
end

.visit(screen) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/journeyviz.rb', line 24

def visit(screen)
  # TODO
  # screen/day/:day/visits ++
  # screen/week/:week/visits ++
  # screen/month/:month/visits ++
  # screen/quarter/:quarter/visits ++
end