Class: Concentric
- Inherits:
-
Object
- Object
- Concentric
- Defined in:
- lib/kojac/concentric.rb
Overview
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
Defined Under Namespace
Modules: Model
Class Method Summary collapse
Class Method Details
.lookup_ring(aRingName) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# 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 |
.ring_name(aRing) ⇒ Object
65 66 67 68 |
# File 'lib/kojac/concentric.rb', line 65 def self.ring_name(aRing) ring_names = Concentric.config[:ring_names] ring_names.key(aRing) end |
.ring_text(aRing) ⇒ Object
70 71 72 73 |
# File 'lib/kojac/concentric.rb', line 70 def self.ring_text(aRing) return 'none' if !aRing ring_name(aRing).to_s.humanize end |