Class: ClarkKent::SharingScope

Inherits:
Object
  • Object
show all
Defined in:
app/models/clark_kent/sharing_scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, parent) ⇒ SharingScope

Returns a new instance of SharingScope.



6
7
8
9
# File 'app/models/clark_kent/sharing_scope.rb', line 6

def initialize(record, parent)
  @record = record
  @parent = parent
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



4
5
6
# File 'app/models/clark_kent/sharing_scope.rb', line 4

def parent
  @parent
end

Instance Method Details

#dom_idObject



11
12
13
14
15
# File 'app/models/clark_kent/sharing_scope.rb', line 11

def dom_id
  str = parent.type
  str += "_#{@record.id}" if @record.respond_to? :id
  str += "_reports"
end

#human_nameObject



17
18
19
20
21
22
23
# File 'app/models/clark_kent/sharing_scope.rb', line 17

def human_name
  if @record.respond_to? :name
    @record.name
  else
    @record
  end
end

#reportsObject



25
26
27
28
29
30
31
# File 'app/models/clark_kent/sharing_scope.rb', line 25

def reports
  if 'Everyone' == @record
    ClarkKent::Report.shared
  else
    @record.clark_kent_reports
  end
end