Class: CanTango::PermissionEngine::Statement

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, action, conditions = {}) ⇒ Statement

Returns a new instance of Statement.



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

def initialize method, action, conditions = {}
  @method, @action, @conditions = [method, action, conditions]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



4
5
6
# File 'lib/cantango/permission_engine/statement.rb', line 4

def action
  @action
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



4
5
6
# File 'lib/cantango/permission_engine/statement.rb', line 4

def conditions
  @conditions
end

#methodObject (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/cantango/permission_engine/statement.rb', line 4

def method
  @method
end

Instance Method Details

#to_codeObject



10
11
12
# File 'lib/cantango/permission_engine/statement.rb', line 10

def to_code
  line = conditions.empty? ? "#{method}(:#{action})" : "#{method}(:#{action}, #{conditions})"
end