Sha256: ca8fcf5be4eb0cb1242e299bf315556a0fbad3339e61d3eb3b8de2fc8fb8a205

Contents?: true

Size: 580 Bytes

Versions: 15

Compression:

Stored size: 580 Bytes

Contents

module Aegis
  class Normalization
    
    VERB_NORMALIZATIONS = {
      "edit"   => "update",
      "show"   => "read",
      "list"   => "read",
      "view"   => "read",
      "delete" => "destroy",
      "remove" => "destroy"
    }
    
    def self.normalize_verb(verb)
      VERB_NORMALIZATIONS[verb] || verb
    end
    
    def self.normalize_permission(permission)
      if permission =~ /^([^_]+?)_(.+?)$/
        verb, target = $1, $2
        permission = normalize_verb(verb) + "_" + target
      end
      permission
    end
    
  end
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
cjbottaro-aegis-1.3.0 lib/aegis/normalization.rb
cjbottaro-aegis-1.3.1 lib/aegis/normalization.rb
makandra-aegis-1.1.1 lib/aegis/normalization.rb
makandra-aegis-1.1.2 lib/aegis/normalization.rb
aegis-1.1.8 lib/aegis/normalization.rb
thelinuxlich-aegis-1.1.9 lib/aegis/normalization.rb
thelinuxlich-aegis-1.1.8 lib/aegis/normalization.rb
thelinuxlich-aegis-1.1.7 lib/aegis/normalization.rb
aegis-1.1.7 lib/aegis/normalization.rb
bmaland-aegis-1.1.6 lib/aegis/normalization.rb
aegis-1.1.6 lib/aegis/normalization.rb
aegis-1.1.5 lib/aegis/normalization.rb
bmaland-aegis-1.1.5 lib/aegis/normalization.rb
aegis-1.1.4 lib/aegis/normalization.rb
aegis-1.1.3 lib/aegis/normalization.rb