Sha256: 2f0faa9204c96cf8830ac100c9371874f7b87891002b3635bbcefbb9dbe44039

Contents?: true

Size: 748 Bytes

Versions: 4

Compression:

Stored size: 748 Bytes

Contents

# coding: utf-8
module MetaTitles
  module Action

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def build_meta_titles
        unless included_modules.include? InstanceMethods
          include InstanceMethods
        end
        before_filter :build_meta_title
      end
    end

    module InstanceMethods
      def yml_tag(type)
        controller = params[:controller]
        prefix = controller.include?('/') ? controller.split('/')[0] : 'root'
        action = params[:static_id] || action_name
        I18n.t("meta_titles.#{prefix}.#{controller_name}.#{action}")
      end

      def build_meta_title
        @meta_title = yml_tag("title") if yml_tag("title")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
meta_titles-0.0.14 lib/meta_titles/meta_titles.rb
meta_titles-0.0.12 lib/meta_titles/meta_titles.rb
meta_titles-0.0.11 lib/meta_titles/meta_titles.rb
meta_titles-0.0.1 lib/meta_titles/meta_titles.rb