Sha256: af6967fd8ab68582592520722526d900ab4508299e509af9d18be104f125de02

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module Eastwood
  module Context

    def app
      Eastwood.application_name
    end

    def env
      Eastwood.env
    end

    def target
      env === 'test' ? '( @window = { } )' : 'window'
    end

    def routes
      # TODO would kind of like to find a better way to transform
      # these values into my routes, but keep as a hash
      # http://www.ruby-forum.com/topic/185611
      named_routes.merge( named_routes ) { |key, route| route_class.new route, route_format }
    end

    def hashes
      # TODO would kind of like to find a better way to transform
      # these values into my routes, but keep as a hash
      # http://www.ruby-forum.com/topic/185611
      named_hashes.merge( named_hashes ){ |key, hash| HashRoute.new key, hash }
    end

    def exports
      Eastwood.exports
    end

    def route_format
      omit_route_format? ? '' : ".#{Eastwood.default_route_format.to_s}"
    end

    protected

    def route_class
      defined?(Journey) ? JourneyRoute : ActionRoute
    end

    def omit_route_format?
      [ '', false ].include? Eastwood.default_route_format
    end

    def named_hashes
      Eastwood.hashes
    end

    def named_routes
      Eastwood.named_routes
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eastwood-0.3.7 lib/eastwood/context.rb
eastwood-0.3.5 lib/eastwood/context.rb