class Concentric
Update: 2015-03-26
-
Extracted ConcentricPolicy from
Kojac
-
Concentric
is now a way of creating Pundit policies based on ConcentricPolicy. It allows shorthand ring security for
simple scenarios, then allow_filter for refinement and arbitrary complex logic to be implemented
-
Concentric
works on the simple idea that there are 4 basic abilities: read, write, create and delete. -
Read and write apply primarily to fields; create and delete apply to records.
-
Creating a record requires the ability to create the record, then normally you require the ability to write some fields.
-
In order to read a record, you need the ability to read at least one field
-
In order to write to a record, you need the ability to write at least one field
-
In order to delete a record, you need the ability to delete the record
-
With
Concentric
you first use the ring and
implement Pundit Policy classes and methods (eg. update? show?) by querying these 4 abilities
Public Class Methods
# File lib/kojac/concentric.rb, line 55 def self.lookup_ring(aRingName) return nil if !aRingName return aRingName if aRingName.is_a?(Fixnum) if ring_names = Concentric.config[:ring_names] return ring_names[aRingName.to_sym] else return nil end end
# File lib/kojac/concentric.rb, line 65 def self.ring_name(aRing) ring_names = Concentric.config[:ring_names] ring_names.key(aRing) end
# File lib/kojac/concentric.rb, line 70 def self.ring_text(aRing) return 'none' if !aRing ring_name(aRing).to_s.humanize end