Module: ActsAsVotable::Extenders::Votable

Defined in:
lib/acts_as_votable/extenders/votable.rb

Constant Summary collapse

ALLOWED_CACHEABLE_STRATEGIES =
i[update update_columns]

Instance Method Summary collapse

Instance Method Details

#acts_as_votable(args = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/acts_as_votable/extenders/votable.rb', line 12

def acts_as_votable(args = {})
  include ActsAsVotable::Votable

  if args.key?(:cacheable_strategy) && !ALLOWED_CACHEABLE_STRATEGIES.include?(args[:cacheable_strategy])
    raise ArgumentError, args[:cacheable_strategy]
  end

  define_method :acts_as_votable_options do
    self.class.instance_variable_get("@acts_as_votable_options")
  end

  class_eval do
    @acts_as_votable_options = {
      cacheable_strategy: :update
    }.merge(args)

    def self.votable?
      true
    end
  end
end

#votable?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/acts_as_votable/extenders/votable.rb', line 8

def votable?
  false
end