Sha256: 1df866a2849e331b43b5c134773d3c91fc1479d5e93acd4b52c187fe24d1c6cd

Contents?: true

Size: 928 Bytes

Versions: 2

Compression:

Stored size: 928 Bytes

Contents

require 'active_support'
require 'frontkit-rails/serializer'
require 'frontkit-rails/state'
require 'frontkit-rails/meta_container'


module FrontKit
  module Base
    extend ActiveSupport::Concern

    included do
      helper_method :frontend_state, :push_frontend_state,
                    :merge_frontend_state, :meta_tags_container,
                    :push_meta_tag
    end

    # instance methods

    def frontend_state
      @_frontend_state ||= FrontKit::State.new(
        production: Rails.env.production?,
        alert: alert,
        notice: notice
      )
    end

    def push_frontend_state(key, value)
      frontend_state[key] = value
    end

    def merge_frontend_state(hash)
      frontend_state.deep_merge!(hash)
    end

    def meta_tags_container
      @_meta_tags_container ||= FrontKit::MetaContainer.new
    end

    def push_meta_tag(hash)
      meta_tags_container.push(hash)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frontkit-rails-0.0.5 lib/frontkit-rails/base.rb
frontkit-rails-0.0.4 lib/frontkit-rails/base.rb