module EffectiveStyleGuide

Constants

VERSION

Public Class Methods

authorize!(controller, action, resource) click to toggle source
# File lib/effective_style_guide.rb, line 27
def self.authorize!(controller, action, resource)
  raise Effective::AccessDenied unless authorized?(controller, action, resource)
end
authorized?(controller, action, resource) click to toggle source
# File lib/effective_style_guide.rb, line 14
def self.authorized?(controller, action, resource)
  @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact

  return !!authorization_method unless authorization_method.respond_to?(:call)
  controller = controller.controller if controller.respond_to?(:controller)

  begin
    !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
  rescue *@_exceptions
    false
  end
end
colors() click to toggle source
# File lib/effective_style_guide.rb, line 31
def self.colors
  ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'black', 'white', 'gray']
end
drinks() click to toggle source
# File lib/effective_style_guide.rb, line 39
def self.drinks
  ['Coffee', 'Tea', 'Soda']
end
foods() click to toggle source
# File lib/effective_style_guide.rb, line 35
def self.foods
  ['bacon', 'eggs', 'hash browns']
end
grouped_colors() click to toggle source
# File lib/effective_style_guide.rb, line 43
def self.grouped_colors
  {
    'Top' => [['red', 'red'], ['orange', 'orange'], ['yellow', 'yellow']],
    'Middle' => [['green', 'green'], ['blue', 'blue'], ['indigo', 'indigo']],
    'Bottom' => [['violet', 'violet']]
  }
end
setup() { |self| ... } click to toggle source
# File lib/effective_style_guide.rb, line 10
def self.setup
  yield self
end