konduto-ruby 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/konduto-ruby/associations/associations.rb +2 -2
- data/lib/konduto-ruby/attributes.rb +9 -1
- data/lib/konduto-ruby/konduto_base.rb +15 -1
- data/lib/konduto-ruby/{konduto_navigation_info.rb → konduto_navigation.rb} +1 -1
- data/lib/konduto-ruby/konduto_order.rb +2 -2
- data/lib/konduto-ruby/konduto_order_status.rb +1 -1
- data/lib/konduto-ruby/konduto_travel_leg.rb +1 -1
- data/lib/konduto-ruby/validations/class_methods.rb +11 -9
- data/lib/konduto-ruby/validations/validations.rb +1 -1
- data/lib/konduto-ruby.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec1ca77129c269d4fde4b050cf435ea9ac0b0b32505c631677f49432bdf08f09
|
4
|
+
data.tar.gz: 1da2a417aa8806fbd456231f901a98a07f3080f4c1258aa74ff3434d9322570e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3db33a75125fa3849aebf4b7c8f10f3f76a19f323f983f8c1cf2de3f7e6fe9dd1975286c8a9b7cead9a034cfdb82698266cc0eb9b3a4faac219de203239ccea
|
7
|
+
data.tar.gz: c8ad6cebe2be3175652ddba10dca045da749825b3acb5caa0c081909febac638cb97e9814f17d107e60e5b71be82b9778a3a23158ce7f23b51067e3f87bd9f70
|
@@ -5,7 +5,7 @@ module Konduto
|
|
5
5
|
name = options[:alias] || model
|
6
6
|
|
7
7
|
self.send(:define_method, name) do
|
8
|
-
instance_variable_get("@#{name}")
|
8
|
+
instance_variable_get("@#{name}") if instance_variable_defined?("@#{name}")
|
9
9
|
end
|
10
10
|
|
11
11
|
self.send(:define_method, "#{name}=".to_sym) do |value|
|
@@ -25,7 +25,7 @@ module Konduto
|
|
25
25
|
name = options[:alias] || model
|
26
26
|
|
27
27
|
self.send(:define_method, name) do
|
28
|
-
instance_variable_get("@#{name}")
|
28
|
+
instance_variable_get("@#{name}") if instance_variable_defined?("@#{name}")
|
29
29
|
end
|
30
30
|
|
31
31
|
self.send(:define_method, "#{name}=".to_sym) do |arr|
|
@@ -6,6 +6,8 @@ module Konduto
|
|
6
6
|
klass = attribute.values[0].to_s.gsub(/_/, ' ').split.map(&:capitalize).join('')
|
7
7
|
type = Object::const_get(klass)
|
8
8
|
name = attribute.keys[0]
|
9
|
+
|
10
|
+
define_strftime_pattern(self, name, attribute[:strftime_pattern]) if attribute.has_key?(:strftime_pattern)
|
9
11
|
else
|
10
12
|
name = attribute
|
11
13
|
end
|
@@ -22,11 +24,17 @@ module Konduto
|
|
22
24
|
end
|
23
25
|
|
24
26
|
self.send(:define_method, name) do
|
25
|
-
instance_variable_get("@#{name.to_s.gsub(/[?|!]$/, '')}")
|
27
|
+
instance_variable_get("@#{name.to_s.gsub(/[?|!]$/, '')}") if instance_variable_defined?("@#{name.to_s.gsub(/[?|!]$/, '')}")
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
alias :attribute :attributes
|
33
|
+
|
34
|
+
def define_strftime_pattern(klass, name, value)
|
35
|
+
klass.send(:define_method, "#{name.to_s.gsub(/[?|!]$/, '')}_strftime_pattern") do
|
36
|
+
value
|
37
|
+
end
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
@@ -28,11 +28,17 @@ class KondutoBase
|
|
28
28
|
instance_variables.map do |name|
|
29
29
|
value = instance_variable_get(name)
|
30
30
|
|
31
|
+
strftime_pattern = defined_strftime_pattern(name) if defined_strftime_pattern?(name)
|
32
|
+
|
31
33
|
if value.respond_to? :each
|
32
34
|
value = value.map {|v| v.to_hash }
|
33
35
|
elsif !value.instance_variables.empty?
|
34
36
|
value = value.to_hash
|
35
|
-
elsif value.is_a?(
|
37
|
+
elsif value.is_a?(DateTime)
|
38
|
+
value = value.strftime(strftime_pattern || '%Y-%m-%dT%H:%MZ')
|
39
|
+
elsif value.is_a?(Date)
|
40
|
+
value = value.strftime(strftime_pattern || '%Y-%m-%d')
|
41
|
+
elsif value.is_a?(Symbol)
|
36
42
|
value = value.to_s
|
37
43
|
end
|
38
44
|
|
@@ -53,4 +59,12 @@ class KondutoBase
|
|
53
59
|
|
54
60
|
true
|
55
61
|
end
|
62
|
+
|
63
|
+
def defined_strftime_pattern?(attr)
|
64
|
+
respond_to? "#{attr.to_s.gsub(/^@/, '')}_strftime_pattern"
|
65
|
+
end
|
66
|
+
|
67
|
+
def defined_strftime_pattern(attr)
|
68
|
+
send("#{attr.to_s.gsub(/^@/, '')}_strftime_pattern")
|
69
|
+
end
|
56
70
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class KondutoNavigation < KondutoBase
|
2
2
|
attributes :session_time, :referrer, :time_site_1d, :new_accounts_1d, :password_resets_1d, :sales_declined_1d,\
|
3
3
|
:sessions_1d, :time_since_last_sale, :time_site_7d, :time_per_page_7d, :new_accounts_7d, \
|
4
4
|
:password_resets_7d, :checkout_count_7d, :sales_declined_7d, :sessions_7d
|
@@ -15,8 +15,8 @@ class KondutoOrder < KondutoBase
|
|
15
15
|
attributes :id, :visitor, :timestamp, :total_amount, :tax_amount, :currency, :installments,
|
16
16
|
:ip, :score, :analyze, :messages_exchanged, :shipping_amount
|
17
17
|
|
18
|
-
attribute first_message: :date_time
|
19
|
-
attribute purchased_at: :date_time
|
18
|
+
attribute first_message: :date_time, strftime_pattern: '%Y-%m-%dT%H:%M:%SZ'
|
19
|
+
attribute purchased_at: :date_time, strftime_pattern: '%Y-%m-%dT%H:%M:%SZ'
|
20
20
|
attribute status: :symbol
|
21
21
|
attribute recommendation: :symbol
|
22
22
|
|
@@ -1,14 +1,16 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Konduto
|
2
|
+
module ClassMethods
|
3
|
+
def validates_presence_of(*attributes)
|
4
|
+
self.send(:define_method, :required_attr) do
|
5
|
+
attributes
|
6
|
+
end
|
5
7
|
end
|
6
|
-
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def validates(*attributes, &block)
|
10
|
+
if block_given?
|
11
|
+
self.send(:define_method, :custom_validations) do
|
12
|
+
{ Proc.new(&block) => attributes }
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
data/lib/konduto-ruby.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konduto-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Custodio
|
@@ -46,7 +46,7 @@ files:
|
|
46
46
|
- lib/konduto-ruby/konduto_geolocation.rb
|
47
47
|
- lib/konduto-ruby/konduto_item.rb
|
48
48
|
- lib/konduto-ruby/konduto_loyalty.rb
|
49
|
-
- lib/konduto-ruby/
|
49
|
+
- lib/konduto-ruby/konduto_navigation.rb
|
50
50
|
- lib/konduto-ruby/konduto_order.rb
|
51
51
|
- lib/konduto-ruby/konduto_order_status.rb
|
52
52
|
- lib/konduto-ruby/konduto_passenger.rb
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
80
|
+
rubygems_version: 3.0.8
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: ''
|