module Aygabtu::Scope::Action

Public Class Methods

factory_methods() click to toggle source
# File lib/aygabtu/scope/action.rb, line 33
def self.factory_methods
  [:action]
end

Public Instance Methods

action(*actions) click to toggle source
# File lib/aygabtu/scope/action.rb, line 4
def action(*actions)
  raise "nesting/chaining action scopes makes no sense" if @data[:action]

  new_data = @data.dup.merge(actions: actions.map(&:to_s))
  self.class.new(new_data)
end
inspect_data() click to toggle source
Calls superclass method
# File lib/aygabtu/scope/action.rb, line 28
def inspect_data
  return super unless actions = @data[:actions]
  super.merge(action: actions.map(&:inspect).join('; '))
end
matches_route?(route) click to toggle source
Calls superclass method
# File lib/aygabtu/scope/action.rb, line 11
def matches_route?(route)
  if @data[:actions]
    @data[:actions].include?(route.action)
  else
    true
  end && super
end
segments_split_once() click to toggle source
Calls superclass method
# File lib/aygabtu/scope/action.rb, line 19
def segments_split_once
  return super unless Array(@data[:actions]).length > 1

  @data[:actions].map do |action|
    new_data = @data.merge(actions: [action])
    self.class.new(new_data)
  end
end