Class: Tags::Authz

Inherits:
Tag show all
Defined in:
app/models/authz.rb

Constant Summary

Constants inherited from Tag

Tag::TYPE_AUTH, Tag::TYPE_NORMAL

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tag

description, find_tag_class, #label, #labeled?, type_id, #unlabel

Methods inherited from BaseNew

Proxy, install_data, install_data_hooks, #with_timestamps?

Class Method Details

.authz_collectionsObject



28
29
30
# File 'app/models/authz.rb', line 28

def self.authz_collections
  @authz_collections
end

.authz_evaluate?(authz_class) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
# File 'app/models/authz.rb', line 36

def self.authz_evaluate?(authz_class)
  unless authz_class < Authz
    raise ArgumentError, "Can't compare the class does not have the root with #{self}"
  end
  authz_class == self
end

.define_authz(klass_name, &blk) ⇒ Object



21
22
23
24
25
26
# File 'app/models/authz.rb', line 21

def self.define_authz(klass_name, &blk)
  c = Class.new(Authz, &blk)
  @authz_collections ||= {}
  @authz_collections.store(c.type_id,klass_name)
  self.const_set(klass_name.to_sym, c)
end

Instance Method Details

#accept_mapping?(taggable_obj) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/authz.rb', line 32

def accept_mapping?(taggable_obj)
  taggable_obj.is_a?(Models::User) && !taggable_obj.accounts_dataset.filter(:account_id=>self.).empty?
end

#after_initializeObject



43
44
45
46
47
# File 'app/models/authz.rb', line 43

def after_initialize
  super
  # Set default name for the :name column.
  self[:name] = self.class.to_s.sub(/^Tags::/, '')
end