Module: WhitelistScope

Defined in:
lib/whitelist_scope.rb,
lib/whitelist_scope/version.rb

Constant Summary collapse

VERSION =
"0.1.4".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#whitelistObject (readonly)

Returns the value of attribute whitelist.



4
5
6
# File 'lib/whitelist_scope.rb', line 4

def whitelist
  @whitelist
end

Instance Method Details

#call_whitelisted_scope(*scope_names) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/whitelist_scope.rb', line 18

def call_whitelisted_scope(*scope_names)
  existing_scope = nil

  scope_names.flatten.each do |scope_name|
    existing_scope = call_scope_by_name(existing_scope, scope_name)
  end
  existing_scope
end

#whitelist_scope(name, body) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/whitelist_scope.rb', line 6

def whitelist_scope(name, body)
  @whitelist ||= []
  name = name.to_sym

  if respond_to?(name)
    raise ArgumentError, "Could not create scope, There is an existing method with this name."
  end

  scope name, body
  @whitelist << name
end