class Ez::Permissions::Resource

Constants

ACTIONS

Attributes

actions[R]
group[R]
label[R]
model[R]
name[R]

Public Class Methods

new(name, options = {}) click to toggle source
# File lib/ez/permissions/resource.rb, line 10
def initialize(name, options = {})
  @name    = name
  @model   = options.fetch(:model, nil)
  @actions = process_actions(options.fetch(:actions, []))
  @group   = options.fetch(:group, :others)
  @label   = options.fetch(:label, name.to_s.humanize)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/ez/permissions/resource.rb, line 18
def <=>(other)
  name <=> other.name
end

Private Instance Methods

process_actions(actions) click to toggle source
# File lib/ez/permissions/resource.rb, line 24
def process_actions(actions)
  return ACTIONS if actions.empty?

  actions.map { |action| action == :crud ? ACTIONS : action }.flatten
end