Module: EffectiveStyleGuide

Defined in:
lib/effective_style_guide.rb,
lib/effective_style_guide/engine.rb,
lib/effective_style_guide/version.rb,
lib/generators/effective_style_guide/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Engine

Constant Summary collapse

VERSION =
'2.0.4'.freeze

Class Method Summary collapse

Class Method Details

.authorize!(controller, action, resource) ⇒ Object



27
28
29
# 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) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
# 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

.colorsObject



31
32
33
# File 'lib/effective_style_guide.rb', line 31

def self.colors
  ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'black', 'white', 'gray']
end

.drinksObject



39
40
41
# File 'lib/effective_style_guide.rb', line 39

def self.drinks
  ['Coffee', 'Tea', 'Soda']
end

.foodsObject



35
36
37
# File 'lib/effective_style_guide.rb', line 35

def self.foods
  ['bacon', 'eggs', 'hash browns']
end

.grouped_colorsObject



43
44
45
46
47
48
49
# 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| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



10
11
12
# File 'lib/effective_style_guide.rb', line 10

def self.setup
  yield self
end