Class: Picky::Index::Hints

Inherits:
Object show all
Defined in:
lib/picky/index/hints.rb

Constant Summary collapse

@@allowed_hints =

Check if all hints are allowed

[:no_dump]

Instance Method Summary collapse

Constructor Details

#initialize(hints) ⇒ Hints

Returns a new instance of Hints.



6
7
8
# File 'lib/picky/index/hints.rb', line 6

def initialize hints
  @hints = check hints
end

Instance Method Details

#check(hints) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/picky/index/hints.rb', line 13

def check hints
  hints.each do |hint|
    unless @@allowed_hints.include?(hint)
      raise <<-ERROR
        Picky cannot optimize for #{hint}.
        Allowed hints are:
          #{@@allowed_hints.join("\n")}
      ERROR
    end
  end
  hints
end

#does?(hint) ⇒ Boolean

Tells us if the user intends to e.g. not dump the indexes.

E.g. hints.does?(:no_dump) # => true/false

Returns:

  • (Boolean)


30
31
32
# File 'lib/picky/index/hints.rb', line 30

def does? hint
  @hints.include? hint
end