Sha256: 011bc03134d136d6746be058c6848596a829d534286691259b4d3f2312fd1fcd

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 Bytes

Contents

module Crumbs
  class Definitions
    class << self
    
      def all
        @all ||= {}
      end
    
      def add(controller, action, name)
        if all.has_key? controller
          all[controller][action] = name
        else
          all[controller] = { action => name }
        end
      end
  
      def find(controller, action, params)
        if all.has_key? controller and all[controller].has_key? action
          name = all[controller][action]
          name.is_a?(Proc) ? name.call(params) : name
        end
      end
  
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crumbs-1.1.2 lib/crumbs/definitions.rb
crumbs-1.1.0 lib/crumbs/definitions.rb
crumbs-1.0.9 lib/crumbs/definitions.rb