active_object 4.0.14 → 5.0.1

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.
@@ -1,101 +1,105 @@
1
- module ActiveObject::Object
2
- FALSE_VALUES ||= [false, 0, '0', 'false', 'FALSE', 'f', 'F'].freeze
3
- TRUE_VALUES ||= [true, 1, '1', 'true', 'TRUE', 't', 'T'].freeze
1
+ # frozen_string_literal: true
4
2
 
5
- def array?
6
- is_a?(Array)
7
- end
3
+ module ActiveObject
4
+ module Object
5
+ FALSE_VALUES ||= [false, 0, '0', 'false', 'FALSE', 'f', 'F'].freeze
6
+ TRUE_VALUES ||= [true, 1, '1', 'true', 'TRUE', 't', 'T'].freeze
8
7
 
9
- def blank?
10
- object = self
11
- object = object.strip if respond_to?(:strip)
12
- respond_to?(:empty?) ? object.empty? : !object
13
- end
8
+ def array?
9
+ is_a?(Array)
10
+ end
14
11
 
15
- def boolean?
16
- TRUE_VALUES.include?(self) || FALSE_VALUES.include?(self)
17
- end
12
+ def blank?
13
+ object = self
14
+ object = object.strip if respond_to?(:strip)
15
+ respond_to?(:empty?) ? object.empty? : !object
16
+ end
18
17
 
19
- # rubocop:disable Style/YodaCondition
20
- def false?
21
- false == self
22
- end
23
- # rubocop:enable Style/YodaCondition
18
+ def boolean?
19
+ TRUE_VALUES.include?(self) || FALSE_VALUES.include?(self)
20
+ end
24
21
 
25
- def falsey?
26
- nil? || FALSE_VALUES.include?(self)
27
- end
22
+ # rubocop:disable Style/YodaCondition
23
+ def false?
24
+ false == self
25
+ end
26
+ # rubocop:enable Style/YodaCondition
28
27
 
29
- def float?
30
- is_a?(Float)
31
- end
28
+ def falsey?
29
+ nil? || FALSE_VALUES.include?(self)
30
+ end
32
31
 
33
- def hash?
34
- is_a?(Hash)
35
- end
32
+ def float?
33
+ is_a?(Float)
34
+ end
36
35
 
37
- def integer?
38
- is_a?(Integer)
39
- end
36
+ def hash?
37
+ is_a?(Hash)
38
+ end
40
39
 
41
- def numeral?
42
- !to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/).nil?
43
- end
40
+ def integer?
41
+ is_a?(Integer)
42
+ end
44
43
 
45
- def numeric?
46
- is_a?(Numeric)
47
- end
44
+ def numeral?
45
+ !to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/).nil?
46
+ end
48
47
 
49
- def palindrome?
50
- to_s == to_s.reverse
51
- end
48
+ def numeric?
49
+ is_a?(Numeric)
50
+ end
52
51
 
53
- def present?
54
- !blank?
55
- end
52
+ def palindrome?
53
+ to_s == to_s.reverse
54
+ end
56
55
 
57
- def range?
58
- is_a?(Range)
59
- end
56
+ def present?
57
+ !blank?
58
+ end
60
59
 
61
- def salvage(placeholder = '---')
62
- blank? ? placeholder : self
63
- end
60
+ def range?
61
+ is_a?(Range)
62
+ end
64
63
 
65
- def send_chain(*keys)
66
- Array(keys).inject(self) { |obj, key| obj.send(*key) }
67
- end
64
+ def salvage(placeholder = '---')
65
+ blank? ? placeholder : self
66
+ end
68
67
 
69
- def string?
70
- is_a?(String)
71
- end
68
+ def send_chain(*keys)
69
+ Array(keys).inject(self) { |obj, key| obj.send(*key) }
70
+ end
72
71
 
73
- def time?
74
- is_a?(Time)
75
- end
72
+ def string?
73
+ is_a?(String)
74
+ end
76
75
 
77
- # rubocop:disable Style/YodaCondition
78
- def true?
79
- true == self
80
- end
81
- # rubocop:enable Style/YodaCondition
76
+ def time?
77
+ is_a?(Time)
78
+ end
82
79
 
83
- def truthy?
84
- TRUE_VALUES.include?(self)
85
- end
80
+ # rubocop:disable Style/YodaCondition
81
+ def true?
82
+ true == self
83
+ end
84
+ # rubocop:enable Style/YodaCondition
86
85
 
87
- def try(*obj, &block)
88
- try!(*obj, &block) if obj.empty? || respond_to?(obj.first)
89
- end
86
+ def truthy?
87
+ TRUE_VALUES.include?(self)
88
+ end
90
89
 
91
- def try!(*obj, &block)
92
- if obj.empty? && block_given?
93
- block.arity.zero? ? instance_eval(&block) : yield(self)
94
- else
95
- public_send(*obj, &block)
90
+ def try(*obj, &block)
91
+ try!(*obj, &block) if obj.empty? || respond_to?(obj.first)
96
92
  end
97
- end
98
93
 
94
+ def try!(*obj, &block)
95
+ if obj.empty? && block_given?
96
+ block.arity.zero? ? instance_eval(&block) : yield(self)
97
+ else
98
+ public_send(*obj, &block)
99
+ end
100
+ end
101
+
102
+ end
99
103
  end
100
104
 
101
- Object.include(ActiveObject::Object) if ActiveObject::Settings.config.autoload_object
105
+ Object.include(ActiveObject::Object) if ActiveObject.configuration.autoload_object
@@ -1,34 +1,38 @@
1
- module ActiveObject::Range
1
+ # frozen_string_literal: true
2
2
 
3
- def combine(other)
4
- to_a.concat(other.to_a)
5
- end
3
+ module ActiveObject
4
+ module Range
6
5
 
7
- def include_with_range?(other)
8
- if other.is_a?(::Range)
9
- operator = exclude_end? && !other.exclude_end? ? :< : :<=
10
- include?(other.first) && other.last.send(operator, last)
11
- else
12
- include?(other)
6
+ def combine(other)
7
+ to_a.concat(other.to_a)
13
8
  end
14
- end
15
9
 
16
- def overlaps?(other)
17
- cover?(other.first) || other.cover?(first)
18
- end
10
+ def include_with_range?(other)
11
+ if other.is_a?(Range)
12
+ operator = exclude_end? && !other.exclude_end? ? :< : :<=
13
+ include?(other.first) && other.last.send(operator, last)
14
+ else
15
+ include?(other)
16
+ end
17
+ end
19
18
 
20
- def sample
21
- to_a.sample
22
- end
19
+ def overlaps?(other)
20
+ cover?(other.first) || other.cover?(first)
21
+ end
23
22
 
24
- def shuffle
25
- to_a.shuffle
26
- end
23
+ def sample
24
+ to_a.sample
25
+ end
27
26
 
28
- def within?(other)
29
- cover?(other.first) && cover?(other.last)
30
- end
27
+ def shuffle
28
+ to_a.shuffle
29
+ end
31
30
 
31
+ def within?(other)
32
+ cover?(other.first) && cover?(other.last)
33
+ end
34
+
35
+ end
32
36
  end
33
37
 
34
- Range.include(ActiveObject::Range) if ActiveObject::Settings.config.autoload_range
38
+ Range.include(ActiveObject::Range) if ActiveObject.configuration.autoload_range