Sha256: 000f6bb74c243f95f6a7bd33d408912e6a1cc5fba987ccfd395ea6734b7fa0eb

Contents?: true

Size: 925 Bytes

Versions: 10

Compression:

Stored size: 925 Bytes

Contents

module Mokio
  module Concerns
    module Models
      #
      # Concern for Meta model
      #
      module Meta
        extend ActiveSupport::Concern

        included do
          has_many :menus
          has_many :contents

          accepts_nested_attributes_for :contents
          accepts_nested_attributes_for :menus

          after_save :touch_many
        end

        module ClassMethods
          def meta_attributes
            [:g_title, :g_desc, :g_keywords, :g_author, :g_copyright, :g_application_name, :f_title, :f_type, :f_image, :f_url, :f_desc, :id]
          end
        end

        #
        # Touching etag after updating meta
        #
        def touch_many
          menu    = Mokio::Menu.find_by_meta_id(self.id)
          content = Mokio::Content.find_by_meta_id(self.id)
          
          menu.touch if menu
          content.touch(:etag) if content
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mokio-0.0.15 lib/mokio/concerns/models/meta.rb
mokio-0.0.14 lib/mokio/concerns/models/meta.rb
mokio-0.0.13 lib/mokio/concerns/models/meta.rb
mokio-0.0.12 lib/mokio/concerns/models/meta.rb
mokio-0.0.11 lib/mokio/concerns/models/meta.rb
mokio-0.0.10 lib/mokio/concerns/models/meta.rb
mokio-0.0.9 lib/mokio/concerns/models/meta.rb
mokio-0.0.8 lib/mokio/concerns/models/meta.rb
mokio-0.0.6 lib/mokio/concerns/models/meta.rb
mokio-0.0.5 lib/mokio/concerns/models/meta.rb