Sha256: 3ac0da0e12c7b0f8c5fef15276d7da1c2e9d17a910fa44e83e76729e0d0210a0

Contents?: true

Size: 630 Bytes

Versions: 3

Compression:

Stored size: 630 Bytes

Contents

# coding: UTF-8
module Rescue
  module Controller
    class Flash

      def self.message object, action, key 
        controllers = object.class.name.gsub('Controller', '').split('::').map {|e| e.underscore }
        scope = ([:views] + controllers) << action << :flash
        text(key, scope)
      end

      def self.default key
        s = I18n.t(key, scope: [:default, :flash], default: '')
        s.blank? ? nil : s
      end

      def self.text key, scope = []
        s = I18n.t(key, scope: scope, default: '')
        s.blank? ? default(key) : s
      end
      private_class_method :default, :text
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rescue-dog-0.3.2 lib/rescue/controllers/flash.rb
rescue-dog-0.3.1 lib/rescue/controllers/flash.rb
rescue-dog-0.3.0 lib/rescue/controllers/flash.rb