Module: Dossier::Model

Included in:
MultiReport, Report
Defined in:
lib/dossier/model.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.anonymous_reportObject



19
20
21
# File 'lib/dossier/model.rb', line 19

def self.anonymous_report
  'AnonymousReport'
end

.class_to_name(klass) ⇒ Object



11
12
13
# File 'lib/dossier/model.rb', line 11

def self.class_to_name(klass)
  (klass.name || anonymous_report).underscore[0..-8]
end

.included(base) ⇒ Object

not using ActiveSupport::Concern because ClassMethods must be extended after ActiveModel::Naming



6
7
8
9
# File 'lib/dossier/model.rb', line 6

def self.included(base)
  base.extend ActiveModel::Naming
  base.extend ClassMethods
end

.name_to_class(name) ⇒ Object



15
16
17
# File 'lib/dossier/model.rb', line 15

def self.name_to_class(name)
  "#{name}_report".classify.constantize
end

Instance Method Details

#persisted?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/dossier/model.rb', line 35

def persisted?
  true
end

#to_keyObject



23
24
25
# File 'lib/dossier/model.rb', line 23

def to_key
  [report_name]
end

#to_modelObject



31
32
33
# File 'lib/dossier/model.rb', line 31

def to_model
  self
end

#to_sObject



27
28
29
# File 'lib/dossier/model.rb', line 27

def to_s
  report_name
end