Module: Wakari::Translation::Model

Extended by:
ActiveSupport::Concern
Includes:
Support::Naming
Defined in:
lib/wakari/models/translation/model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#_destroy=(value) ⇒ Object



89
90
91
92
93
94
# File 'lib/wakari/models/translation/model.rb', line 89

def _destroy=(value)
  case value
  when 1, '1', true, 'true' then
    mark_for_destruction
  end
end

#changed?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/wakari/models/translation/model.rb', line 110

def changed?
  meta_changed? || super
end

#dom_id(prefix = nil) ⇒ Object



85
86
87
# File 'lib/wakari/models/translation/model.rb', line 85

def dom_id(prefix = nil)
  [prefix, content.dom_id, self.class.dom_class, locale].compact.join("_")
end

#langObject



131
132
133
# File 'lib/wakari/models/translation/model.rb', line 131

def lang
  Gaigo::LANGS.get(locale)
end

#match?(params = {}) ⇒ Boolean

Returns:

  • (Boolean)


122
123
124
125
# File 'lib/wakari/models/translation/model.rb', line 122

def match?(params = {})
  m = params.map {|key, value| send(key) == (value.is_a?(Symbol) ? value.to_s : value)}
  (m.include?(false) || m.blank?) ? false : true
end

#meta_attributesObject



127
128
129
# File 'lib/wakari/models/translation/model.rb', line 127

def meta_attributes
  Hash[_meta_attributes.map {|attr| value = send(attr); [attr.to_s, value] if value}.compact]
end

#meta_changed?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/wakari/models/translation/model.rb', line 114

def meta_changed?
  eval(_meta_attributes.map {|a| "template_meta.send(:#{a}) != meta.send(:#{a})"}.join(" || ")) ## content changed?
end

#meta_counterObject



100
101
102
103
104
# File 'lib/wakari/models/translation/model.rb', line 100

def meta_counter
  counter = association(:meta).options[:counter_cache]
  counter = self.class.model_name.plural + "_count" if counter == true
  meta.send(counter) if counter
end

#meta_valid?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/wakari/models/translation/model.rb', line 118

def meta_valid?
  template_meta.valid?
end

#only_once_used_meta?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/wakari/models/translation/model.rb', line 106

def only_once_used_meta?
  meta_counter && meta_counter <= 1
end

#siblingsObject



96
97
98
# File 'lib/wakari/models/translation/model.rb', line 96

def siblings
  stack - [self]
end

#to_paramObject



135
136
137
# File 'lib/wakari/models/translation/model.rb', line 135

def to_param
  locale
end