Module: Mongoid::Verbalize::Versioning::ClassMethods

Defined in:
lib/mongoid/verbalize/versioning.rb

Instance Method Summary collapse

Instance Method Details

#iterate_verbalized_fields(document, &block) ⇒ Object



30
31
32
33
34
# File 'lib/mongoid/verbalize/versioning.rb', line 30

def iterate_verbalized_fields(document, &block)
  verbalized_fields(document).each do |name, field|
    yield document, field
  end
end

#verbalized_children(document) ⇒ Object



20
21
22
# File 'lib/mongoid/verbalize/versioning.rb', line 20

def verbalized_children(document)
  document._children.reject { |child| !child.class.include?(Mongoid::Verbalize) }
end

#verbalized_field_values(document) ⇒ Object



24
25
26
27
28
# File 'lib/mongoid/verbalize/versioning.rb', line 24

def verbalized_field_values(document)
  verbalized_fields(document).map do |name, field|
    document.send("#{field.name}_translations")
  end
end

#verbalized_fields(document) ⇒ Object



16
17
18
# File 'lib/mongoid/verbalize/versioning.rb', line 16

def verbalized_fields(document)
  document.class.fields.reject { |name, field| field.options[:type] != TranslatedString }
end