Class: Almicube::Selector::MethodSelector

Inherits:
Base
  • Object
show all
Defined in:
lib/almicube/selector/method_selector.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#class_name

Attributes included from Cog

#ranking

Instance Method Summary collapse

Methods inherited from Base

#before_aggregate, #data_provider?, #interstore, #label

Methods included from Cog

#active?, #after_aggregate, #before_aggregate

Constructor Details

#initialize(options = {}) ⇒ MethodSelector

Returns a new instance of MethodSelector.



6
7
8
9
10
11
12
13
# File 'lib/almicube/selector/method_selector.rb', line 6

def initialize(options={})
  super(options)

  @accessor = options[:accessor] || :all
  @counter = options[:counter] || :count

  raise "invalid options" unless valid?
end

Instance Attribute Details

#accessorObject (readonly)

Returns the value of attribute accessor.



4
5
6
# File 'lib/almicube/selector/method_selector.rb', line 4

def accessor
  @accessor
end

#counterObject (readonly)

Returns the value of attribute counter.



4
5
6
# File 'lib/almicube/selector/method_selector.rb', line 4

def counter
  @counter
end

Instance Method Details

#countObject



19
20
21
# File 'lib/almicube/selector/method_selector.rb', line 19

def count
  class_name.send(counter)
end

#recordsObject



15
16
17
# File 'lib/almicube/selector/method_selector.rb', line 15

def records
  class_name.send(accessor)
end

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/almicube/selector/method_selector.rb', line 23

def valid?
  validate_accessor
end