pricing_observer 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pricing_observer/version.rb +1 -1
- data/lib/pricing_observer.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6de3e7fe38515e671b95aa179e1ff6b9e7f81fc
|
4
|
+
data.tar.gz: ed9e58cc44de9b44dc183d8c97c9b85e98d93f77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34d2f9d17cea0be066f7ed75414fe9026075f84be6adea064e1a6a9d3df44c164793956b95d8eb6f751ce2f60099dd1b052890a52ce26963e3857177d7f0cde
|
7
|
+
data.tar.gz: 2107513d5c130f04722c0850e6ccacd437def2ad6fbbe6f9284839a61321730280794a36c06114b02a9839e43644f626f896ff425c290b1aa6b793de129bec5f
|
data/lib/pricing_observer.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
require "pricing_observer/version"
|
2
|
+
#this observer pattern provides reusability class that helps to produce a dynamic pricing strategy for all the products every time the order is confirmed.
|
2
3
|
class OrderSend
|
4
|
+
#this method initializes the observer array to store the observable objects
|
3
5
|
def initialize
|
4
6
|
@observers=[]
|
5
7
|
end
|
6
|
-
|
8
|
+
|
9
|
+
#adds the observable objects into class
|
7
10
|
def add_observer(observer)
|
8
11
|
@observers << observer
|
9
12
|
end
|
10
13
|
|
14
|
+
#deletes the observable objects from the class
|
11
15
|
def delete_observer(observer)
|
12
16
|
@observers.delete(observer)
|
13
17
|
end
|
14
18
|
|
19
|
+
#notify's the observer when an desired condition is triggered
|
15
20
|
def notify_observers
|
16
21
|
@observers.each do |observer|
|
17
22
|
puts "Notifying"
|
@@ -21,13 +26,14 @@ class OrderSend
|
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
24
|
-
|
29
|
+
#this prcing class is the oberser class that triggers the observer functionality
|
25
30
|
class Pricing
|
31
|
+
#this method initializes the class and adds the observer object to observer class
|
26
32
|
def initialize(order)
|
27
33
|
order.add_observer(self)
|
28
34
|
puts "observer initialized"
|
29
35
|
end
|
30
|
-
|
36
|
+
#this is the logical pricing method that is triggered by the observer when ever the condition is met to be executed.
|
31
37
|
def pricing_by_hit
|
32
38
|
#order_record = OrderItem.last
|
33
39
|
#prod = Product.find(order_record.product_id)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pricing_observer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kishore Kumar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|