Class: CheckByHit

Inherits:
BasicWay show all
Defined in:
lib/product_home_template.rb

Overview

this class provides the functionality to inherit the base class to provide the products by ranking highest selling product.

Instance Method Summary collapse

Methods inherited from BasicWay

#with_page, #without_page

Constructor Details

#initialize(param) ⇒ CheckByHit

this method initializes base class object with the store detail



34
35
36
# File 'lib/product_home_template.rb', line 34

def initialize(param)
    super(param)
end

Instance Method Details

#my_special_method(pages) ⇒ Object

this method to run the logic of sorting the products with pagination by ranking the hit



39
40
41
42
43
44
# File 'lib/product_home_template.rb', line 39

def my_special_method(pages)
    @product_by_hits = @store_detail.products.order('hit asc').paginate(page: pages, per_page: 3).take(3)
    puts("===== by hit =====")
    puts(@product_by_hits)
    return @product_by_hits
end

#my_special_method_without(member) ⇒ Object

this method to run the logic of sorting the products without pagination by ranking the hit



47
48
49
50
# File 'lib/product_home_template.rb', line 47

def my_special_method_without(member)
    @product_by_hits = @store_detail.products.order('hit asc').take(3)
    return @product_by_hits
end