Class: Relation::Single

Inherits:
Relation
  • Object
show all
Defined in:
app/models/relation/single.rb

Overview

Common methods for single relations, like Public and Reject

Unlike Custom, subjects have only one of these relations.

Direct Known Subclasses

Follow, Owner, Public, Reject

Constant Summary collapse

PERMISSIONS =
[]

Constants inherited from Relation

Negative, Positive

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Relation

#<=>, allow, allow?, create_activity?, #follow?, ids_shared_with, #mode, negative_names, normalize, normalize_id, #positive?, positive_names, system_list

Class Method Details

.instanceObject



10
11
12
13
14
# File 'app/models/relation/single.rb', line 10

def instance
  @instance ||=
    first ||
      create!(:permissions => permissions)
end

.permissionsObject



16
17
18
# File 'app/models/relation/single.rb', line 16

def permissions
  Permission.instances self::PERMISSIONS
end

Instance Method Details

#available_permissionsObject

The available permissions for Relation::Single match with the permissions described in the variable



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

def available_permissions
  self.class.permissions
end

#nameObject

The name of public relation



22
23
24
# File 'app/models/relation/single.rb', line 22

def name
  I18n.t("relation_#{ self.class.name.split("::").last.underscore }.name")
end