Class: CanTango::Factory::Permits

Inherits:
Object
  • Object
show all
Includes:
Helpers::Debug
Defined in:
lib/cantango/permits_ext/factory/permits.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ability, type) ⇒ Permits

creates the factory for the ability note that the ability contains the roles and role groups of the user (or account)

Parameters:

  • the (Permits::Ability)

    ability



12
13
14
# File 'lib/cantango/permits_ext/factory/permits.rb', line 12

def initialize ability, type
  @ability, @type = [ability, type]
end

Instance Attribute Details

#abilityObject

Returns the value of attribute ability.



6
7
8
# File 'lib/cantango/permits_ext/factory/permits.rb', line 6

def ability
  @ability
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/cantango/permits_ext/factory/permits.rb', line 7

def type
  @type
end

Instance Method Details

#createObject



16
17
18
# File 'lib/cantango/permits_ext/factory/permits.rb', line 16

def create
  permits.build
end

#permitsObject



20
21
22
# File 'lib/cantango/permits_ext/factory/permits.rb', line 20

def permits
  permits_builder.new ability
end

#permits_builderObject



24
25
26
# File 'lib/cantango/permits_ext/factory/permits.rb', line 24

def permits_builder
  permits_builder_class.constantize
end

#permits_builder_classObject



28
29
30
31
# File 'lib/cantango/permits_ext/factory/permits.rb', line 28

def permits_builder_class
  return "CanTango::Builder::Permit::Special" if type == :special
  "CanTango::Builder::Permit::#{type.to_s.camelize}"
end