Class: CanTango::PermissionEngine::Parser::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/cantango/permission_engine/parser/rule.rb

Direct Known Subclasses

Category, Default, Ownership, Regex, Relationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, action, target) ⇒ Rule

Returns a new instance of Rule.



8
9
10
11
12
# File 'lib/cantango/permission_engine/parser/rule.rb', line 8

def initialize method, action, target
  @target = target
  @method = method
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



6
7
8
# File 'lib/cantango/permission_engine/parser/rule.rb', line 6

def action
  @action
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/cantango/permission_engine/parser/rule.rb', line 6

def method
  @method
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/cantango/permission_engine/parser/rule.rb', line 6

def model
  @model
end

#targetObject (readonly)

Returns the value of attribute target.



6
7
8
# File 'lib/cantango/permission_engine/parser/rule.rb', line 6

def target
  @target
end

Instance Method Details

#parseObject



14
15
# File 'lib/cantango/permission_engine/parser/rule.rb', line 14

def parse
end

#parse_class(target = nil) ⇒ Object



17
18
19
20
# File 'lib/cantango/permission_engine/parser/rule.rb', line 17

def parse_class target = nil
  @target = target if target
  try_class.to_s
end

#try_classObject



22
23
24
25
26
# File 'lib/cantango/permission_engine/parser/rule.rb', line 22

def try_class
  target.constantize
rescue
  raise "[permission] target #{target} does not have a class so it was skipped"
end