Sha256: de6dc107495db1a44011ddca49c007c5815de87ebf43b729edd9552a7a8f9631

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

module Crumbs
  class History
    class << self
    
      def all
        @all ||= {}
      end
    
      def add(controller, action, name)
        unless all.has_key? controller.to_sym
          all[controller.to_sym] = { action.to_sym => name }
        else 
          all[controller.to_sym][action.to_sym] = name
        end
      end
  
      def get_name(controller, action, params)
        return false unless all.has_key? controller.to_sym and all[controller.to_sym].has_key? action.to_sym
        name = all[controller.to_sym][action.to_sym]
        case name
        when String
          value = name
        when Proc
          value = name.call(params)
        end
        value ? value : ''
      end
  
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crumbs-1.0.7 lib/crumbs/history.rb