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
- #_destroy=(value) ⇒ Object
- #changed? ⇒ Boolean
- #dom_id(prefix = nil) ⇒ Object
- #lang ⇒ Object
- #match?(params = {}) ⇒ Boolean
- #meta_attributes ⇒ Object
- #meta_changed? ⇒ Boolean
- #meta_counter ⇒ Object
- #meta_valid? ⇒ Boolean
- #only_once_used_meta? ⇒ Boolean
- #siblings ⇒ Object
- #to_param ⇒ Object
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
110 111 112 |
# File 'lib/wakari/models/translation/model.rb', line 110 def 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 |
#lang ⇒ Object
131 132 133 |
# File 'lib/wakari/models/translation/model.rb', line 131 def lang Gaigo::LANGS.get(locale) end |
#match?(params = {}) ⇒ 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_attributes ⇒ Object
127 128 129 |
# File 'lib/wakari/models/translation/model.rb', line 127 def Hash[.map {|attr| value = send(attr); [attr.to_s, value] if value}.compact] end |
#meta_changed? ⇒ Boolean
114 115 116 |
# File 'lib/wakari/models/translation/model.rb', line 114 def eval(.map {|a| "template_meta.send(:#{a}) != meta.send(:#{a})"}.join(" || ")) ## content changed? end |
#meta_counter ⇒ Object
100 101 102 103 104 |
# File 'lib/wakari/models/translation/model.rb', line 100 def counter = association(:meta).[:counter_cache] counter = self.class.model_name.plural + "_count" if counter == true .send(counter) if counter end |
#meta_valid? ⇒ Boolean
118 119 120 |
# File 'lib/wakari/models/translation/model.rb', line 118 def .valid? end |
#only_once_used_meta? ⇒ Boolean
106 107 108 |
# File 'lib/wakari/models/translation/model.rb', line 106 def && <= 1 end |
#siblings ⇒ Object
96 97 98 |
# File 'lib/wakari/models/translation/model.rb', line 96 def siblings stack - [self] end |
#to_param ⇒ Object
135 136 137 |
# File 'lib/wakari/models/translation/model.rb', line 135 def to_param locale end |