Class: RankedModel::Ranker

Inherits:
Object
  • Object
show all
Defined in:
lib/ranked-model/ranker.rb

Defined Under Namespace

Classes: Mapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Ranker

Returns a new instance of Ranker.



9
10
11
12
13
14
15
16
17
# File 'lib/ranked-model/ranker.rb', line 9

def initialize name, options={}
  self.name = name.to_sym
  self.column = options[:column] || name
  self.class_name = options[:class_name]

  [ :scope, :with_same, :unless ].each do |key|
    self.send "#{key}=", options[key]
  end
end

Instance Attribute Details

#class_nameObject

Returns the value of attribute class_name.



7
8
9
# File 'lib/ranked-model/ranker.rb', line 7

def class_name
  @class_name
end

#columnObject

Returns the value of attribute column.



7
8
9
# File 'lib/ranked-model/ranker.rb', line 7

def column
  @column
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/ranked-model/ranker.rb', line 7

def name
  @name
end

#scopeObject

Returns the value of attribute scope.



7
8
9
# File 'lib/ranked-model/ranker.rb', line 7

def scope
  @scope
end

#unlessObject

Returns the value of attribute unless.



7
8
9
# File 'lib/ranked-model/ranker.rb', line 7

def unless
  @unless
end

#with_sameObject

Returns the value of attribute with_same.



7
8
9
# File 'lib/ranked-model/ranker.rb', line 7

def with_same
  @with_same
end

Instance Method Details

#with(instance) ⇒ Object



19
20
21
# File 'lib/ranked-model/ranker.rb', line 19

def with instance
  Mapper.new self, instance
end