Class: Aygabtu::Scope::Base

Inherits:
Object
  • Object
show all
Includes:
[ NamespaceController, Action, Named, VisitingWith, Requiring, StaticDynamic, Remaining ], BasicBehaviour
Defined in:
lib/aygabtu/scope/base.rb

Defined Under Namespace

Modules: BasicBehaviour

Constant Summary collapse

COMPONENTS =
[
  NamespaceController,
  Action,
  Named,
  VisitingWith,
  Requiring,
  StaticDynamic,
  Remaining
]

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BasicBehaviour

#inspect_data, #matches_route?, #segments_split_once

Constructor Details

#initialize(data) ⇒ Base



12
13
14
# File 'lib/aygabtu/scope/base.rb', line 12

def initialize(data)
  @data = data
end

Class Attribute Details

.factory_methodsObject (readonly)

Returns the value of attribute factory_methods.



75
76
77
# File 'lib/aygabtu/scope/base.rb', line 75

def factory_methods
  @factory_methods
end

Class Method Details

.blank_slateObject



20
21
22
# File 'lib/aygabtu/scope/base.rb', line 20

def self.blank_slate
  new(filters: [])
end

Instance Method Details

#inspectObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/aygabtu/scope/base.rb', line 61

def inspect
  data = inspect_data
  data.keys.each { |key| data.delete(key) if data[key].nil? }
  message = if data.empty?
    "nothing specified"
  else
    data.map { |key, value| "#{key}: #{value}" }.join(', ')
  end
  "\#<Aygabtu scope (#{message})>"
end

#segmentsObject



53
54
55
56
57
58
59
# File 'lib/aygabtu/scope/base.rb', line 53

def segments
  if split_once = segments_split_once
    split_once.map(&:segments).reduce(:+)
  else
    [self]
  end
end

#visiting_dataObject



16
17
18
# File 'lib/aygabtu/scope/base.rb', line 16

def visiting_data
  @data.fetch(:visiting_data, {})
end