Sha256: e0c05a55ff4ecfad660d202f3d5af53a9b5bfe79e3d8618bfbb95f07088e0ec2

Contents?: true

Size: 666 Bytes

Versions: 10

Compression:

Stored size: 666 Bytes

Contents

module Picky
  module API
    module Category

      module Weight

        def extract_weight thing
          return Generators::Weights::Default unless thing

          if thing.respond_to? :weight_for
            thing
          elsif thing.respond_to? :to_int
            Generators::Weights::Logarithmic.new thing
          else
            raise <<-ERROR
weight options for #{index_name}:#{name} should be either
* for example a Weights::Logarithmic.new, Weights::Constant.new(int = 0), Weights::Dynamic.new(&block) etc.
or
* an object that responds to #weight_for(amount_of_ids_for_token) => float
ERROR
          end
        end

      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
picky-4.6.3 lib/picky/api/category/weight.rb
picky-4.6.2 lib/picky/api/category/weight.rb
picky-4.6.1 lib/picky/api/category/weight.rb
picky-4.6.0 lib/picky/api/category/weight.rb
picky-4.5.12 lib/picky/api/category/weight.rb
picky-4.5.11 lib/picky/api/category/weight.rb
picky-4.5.10 lib/picky/api/category/weight.rb
picky-4.5.9 lib/picky/api/category/weight.rb
picky-4.5.8 lib/picky/api/category/weight.rb
picky-4.5.7 lib/picky/api/category/weight.rb