Class: Ecm::References::Category

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/ecm/references/category.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.localizedObject



35
36
37
# File 'app/models/ecm/references/category.rb', line 35

def self.localized
  where(locale: I18n.locale)
end

.with_public_visibilityObject



39
40
41
# File 'app/models/ecm/references/category.rb', line 39

def self.with_public_visibility
  localized
end

Instance Method Details

#humanObject



43
44
45
# File 'app/models/ecm/references/category.rb', line 43

def human
  name
end

#locale=(locale) ⇒ Object



47
48
49
# File 'app/models/ecm/references/category.rb', line 47

def locale=(locale)
  write_attribute(:locale, locale.to_s) if locale.respond_to?(:to_s)
end

#locale_label(view) ⇒ Object



51
52
53
# File 'app/models/ecm/references/category.rb', line 51

def locale_label(view)
  view.(:span, locale, class: 'label label-default')
end

#public_references_countObject



59
60
61
# File 'app/models/ecm/references/category.rb', line 59

def public_references_count
  references.with_public_visibility.count
end

#public_references_count_label(view) ⇒ Object



63
64
65
# File 'app/models/ecm/references/category.rb', line 63

def public_references_count_label(view)
  view.(:span, public_references_count, class: 'badge')
end

#references_countObject



55
56
57
# File 'app/models/ecm/references/category.rb', line 55

def references_count
  references.count
end

#to_sObject



67
68
69
# File 'app/models/ecm/references/category.rb', line 67

def to_s
  name
end

#tree_nameObject



71
72
73
# File 'app/models/ecm/references/category.rb', line 71

def tree_name
  name
end