Sha256: d97dd08086d066ff682f5a3bc6565a551e47d281437d7e443609f1df3b0a76ba

Contents?: true

Size: 977 Bytes

Versions: 7

Compression:

Stored size: 977 Bytes

Contents

module I18nline
  module ActionViewExtension
    extend ActiveSupport::Concern

    included do
      def current_user_can_translate?
        current_user = send I18nline.current_user_method
        if current_user
          if current_user.try I18nline.can_translate_method
            I18nline.current_user = current_user
            return true
          end
        end
        false
      end
    end

    def i18nline_assets_inclusion_tag
      if current_user_can_translate?
        assets = ""
        assets << i18nline_host_styles << "\n"
        assets << i18nline_host_javascripts << "\n"
        assets.html_safe
      end
    end

    private

      # Javascripts that will be loaded on host application:
      def i18nline_host_javascripts
        javascript_include_tag("i18nline_to_host.js")
      end

      # Css that will be loaded on host application:
      def i18nline_host_styles
        stylesheet_link_tag("i18nline_to_host.css")
      end

  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
i18nline-0.0.7.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.6.alpha lib/i18nline/action_view_extension.rb
i18nline-rails-0.0.5.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.5.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.4.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.3.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.2.alpha lib/i18nline/action_view_extension.rb