Sha256: 0a47aabd300e1c5ffec57dd61dc860cc55f125d783cb42cb6527c048f4883914

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 Bytes

Contents

module Eastwood
  module Context
    class HashRoute < Struct.new( :key, :hash )
      include RouteHelpers

      def name
        key.to_s
      end

      def parts
        hash.scan( /:(\w+)/ ).flatten.map &:to_sym
      end

      def path
        hash
      end

      def coffee_name
        style_for_javascript "#{name}_hash"
      end

      def coffee_args
        parts.join ', '
      end

      def coffee_path
        path.gsub /:(\w+)/, '#{\1}'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eastwood-0.3.8 lib/eastwood/context/hash_route.rb
eastwood-0.3.7 lib/eastwood/context/hash_route.rb