Sha256: 67ca9c1364efbd943a0f51a7c5793e77d77c42274ca62cd4eee2a94309d35a57

Contents?: true

Size: 777 Bytes

Versions: 7

Compression:

Stored size: 777 Bytes

Contents

class Usher
  class Route
    class Path
  
      attr_reader :dynamic_parts, :dynamic_map, :dynamic_indicies, :route, :parts, :dynamic_required_keys, :dynamic_keys
      
      def initialize(route, parts)
        @route = route
        @parts = parts
        @dynamic_indicies = []
        @parts.each_index{|i| @dynamic_indicies << i if @parts[i].is_a?(Variable)}
        @dynamic_parts = @parts.values_at(*@dynamic_indicies)
        @dynamic_map = {}
        @dynamic_parts.each{|p| @dynamic_map[p.name] = p }
        @dynamic_keys = @dynamic_map.keys
        @dynamic_required_keys = @dynamic_parts.select{|dp| !dp.default_value}.map{|dp| dp.name}
      end

      def can_generate_from?(keys)
        (@dynamic_required_keys - keys).size.zero?
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
joshbuddy-usher-0.4.10 lib/usher/route/path.rb
joshbuddy-usher-0.4.11 lib/usher/route/path.rb
joshbuddy-usher-0.4.5 lib/usher/route/path.rb
joshbuddy-usher-0.4.6 lib/usher/route/path.rb
joshbuddy-usher-0.4.7 lib/usher/route/path.rb
joshbuddy-usher-0.4.8 lib/usher/route/path.rb
usher-0.4.8 lib/usher/route/path.rb