searchlogic 1.6.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG.rdoc +17 -0
  3. data/{MIT-LICENSE → LICENSE} +2 -2
  4. data/README.rdoc +128 -379
  5. data/Rakefile +56 -20
  6. data/VERSION.yml +4 -0
  7. data/init.rb +1 -1
  8. data/lib/searchlogic.rb +18 -98
  9. data/lib/searchlogic/core_ext/object.rb +33 -13
  10. data/lib/searchlogic/core_ext/proc.rb +11 -0
  11. data/lib/searchlogic/named_scopes/alias_scope.rb +63 -0
  12. data/lib/searchlogic/named_scopes/associations.rb +126 -0
  13. data/lib/searchlogic/named_scopes/conditions.rb +215 -0
  14. data/lib/searchlogic/named_scopes/ordering.rb +53 -0
  15. data/lib/searchlogic/rails_helpers.rb +69 -0
  16. data/lib/searchlogic/search.rb +146 -0
  17. data/rails/init.rb +1 -0
  18. data/searchlogic.gemspec +69 -0
  19. data/spec/core_ext/object_spec.rb +7 -0
  20. data/spec/core_ext/proc_spec.rb +9 -0
  21. data/spec/named_scopes/alias_scope_spec.rb +15 -0
  22. data/spec/named_scopes/associations_spec.rb +120 -0
  23. data/spec/named_scopes/conditions_spec.rb +253 -0
  24. data/spec/named_scopes/ordering_spec.rb +23 -0
  25. data/spec/search_spec.rb +283 -0
  26. data/spec/spec_helper.rb +78 -0
  27. metadata +40 -231
  28. data/Manifest.txt +0 -158
  29. data/TODO.rdoc +0 -4
  30. data/lib/searchlogic/active_record/associations.rb +0 -52
  31. data/lib/searchlogic/active_record/base.rb +0 -224
  32. data/lib/searchlogic/active_record/connection_adapters/mysql_adapter.rb +0 -176
  33. data/lib/searchlogic/active_record/connection_adapters/postgresql_adapter.rb +0 -172
  34. data/lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb +0 -80
  35. data/lib/searchlogic/condition/base.rb +0 -165
  36. data/lib/searchlogic/condition/begins_with.rb +0 -17
  37. data/lib/searchlogic/condition/blank.rb +0 -24
  38. data/lib/searchlogic/condition/child_of.rb +0 -11
  39. data/lib/searchlogic/condition/descendant_of.rb +0 -11
  40. data/lib/searchlogic/condition/ends_with.rb +0 -17
  41. data/lib/searchlogic/condition/equals.rb +0 -33
  42. data/lib/searchlogic/condition/greater_than.rb +0 -15
  43. data/lib/searchlogic/condition/greater_than_or_equal_to.rb +0 -15
  44. data/lib/searchlogic/condition/inclusive_descendant_of.rb +0 -10
  45. data/lib/searchlogic/condition/keywords.rb +0 -52
  46. data/lib/searchlogic/condition/less_than.rb +0 -15
  47. data/lib/searchlogic/condition/less_than_or_equal_to.rb +0 -15
  48. data/lib/searchlogic/condition/like.rb +0 -15
  49. data/lib/searchlogic/condition/nested_set.rb +0 -17
  50. data/lib/searchlogic/condition/nil.rb +0 -21
  51. data/lib/searchlogic/condition/not_begin_with.rb +0 -20
  52. data/lib/searchlogic/condition/not_blank.rb +0 -19
  53. data/lib/searchlogic/condition/not_end_with.rb +0 -20
  54. data/lib/searchlogic/condition/not_equal.rb +0 -27
  55. data/lib/searchlogic/condition/not_have_keywords.rb +0 -20
  56. data/lib/searchlogic/condition/not_like.rb +0 -20
  57. data/lib/searchlogic/condition/not_nil.rb +0 -19
  58. data/lib/searchlogic/condition/sibling_of.rb +0 -14
  59. data/lib/searchlogic/conditions/any_or_all.rb +0 -42
  60. data/lib/searchlogic/conditions/base.rb +0 -244
  61. data/lib/searchlogic/conditions/groups.rb +0 -74
  62. data/lib/searchlogic/conditions/magic_methods.rb +0 -286
  63. data/lib/searchlogic/conditions/multiparameter_attributes.rb +0 -105
  64. data/lib/searchlogic/conditions/protection.rb +0 -36
  65. data/lib/searchlogic/config.rb +0 -31
  66. data/lib/searchlogic/config/helpers.rb +0 -338
  67. data/lib/searchlogic/config/search.rb +0 -53
  68. data/lib/searchlogic/core_ext/hash.rb +0 -75
  69. data/lib/searchlogic/helpers/control_types/link.rb +0 -310
  70. data/lib/searchlogic/helpers/control_types/links.rb +0 -242
  71. data/lib/searchlogic/helpers/control_types/remote_link.rb +0 -87
  72. data/lib/searchlogic/helpers/control_types/remote_links.rb +0 -72
  73. data/lib/searchlogic/helpers/control_types/remote_select.rb +0 -36
  74. data/lib/searchlogic/helpers/control_types/select.rb +0 -82
  75. data/lib/searchlogic/helpers/form.rb +0 -208
  76. data/lib/searchlogic/helpers/utilities.rb +0 -197
  77. data/lib/searchlogic/modifiers/absolute.rb +0 -15
  78. data/lib/searchlogic/modifiers/acos.rb +0 -11
  79. data/lib/searchlogic/modifiers/asin.rb +0 -11
  80. data/lib/searchlogic/modifiers/atan.rb +0 -11
  81. data/lib/searchlogic/modifiers/avg.rb +0 -15
  82. data/lib/searchlogic/modifiers/base.rb +0 -27
  83. data/lib/searchlogic/modifiers/ceil.rb +0 -15
  84. data/lib/searchlogic/modifiers/char_length.rb +0 -15
  85. data/lib/searchlogic/modifiers/cos.rb +0 -15
  86. data/lib/searchlogic/modifiers/cot.rb +0 -15
  87. data/lib/searchlogic/modifiers/count.rb +0 -11
  88. data/lib/searchlogic/modifiers/day_of_month.rb +0 -15
  89. data/lib/searchlogic/modifiers/day_of_week.rb +0 -15
  90. data/lib/searchlogic/modifiers/day_of_year.rb +0 -15
  91. data/lib/searchlogic/modifiers/degrees.rb +0 -11
  92. data/lib/searchlogic/modifiers/exp.rb +0 -15
  93. data/lib/searchlogic/modifiers/floor.rb +0 -15
  94. data/lib/searchlogic/modifiers/hex.rb +0 -11
  95. data/lib/searchlogic/modifiers/hour.rb +0 -11
  96. data/lib/searchlogic/modifiers/log.rb +0 -15
  97. data/lib/searchlogic/modifiers/log10.rb +0 -11
  98. data/lib/searchlogic/modifiers/log2.rb +0 -11
  99. data/lib/searchlogic/modifiers/lower.rb +0 -15
  100. data/lib/searchlogic/modifiers/ltrim.rb +0 -15
  101. data/lib/searchlogic/modifiers/md5.rb +0 -11
  102. data/lib/searchlogic/modifiers/microseconds.rb +0 -11
  103. data/lib/searchlogic/modifiers/milliseconds.rb +0 -11
  104. data/lib/searchlogic/modifiers/minute.rb +0 -15
  105. data/lib/searchlogic/modifiers/month.rb +0 -15
  106. data/lib/searchlogic/modifiers/octal.rb +0 -15
  107. data/lib/searchlogic/modifiers/radians.rb +0 -11
  108. data/lib/searchlogic/modifiers/round.rb +0 -11
  109. data/lib/searchlogic/modifiers/rtrim.rb +0 -15
  110. data/lib/searchlogic/modifiers/second.rb +0 -15
  111. data/lib/searchlogic/modifiers/sign.rb +0 -11
  112. data/lib/searchlogic/modifiers/sin.rb +0 -11
  113. data/lib/searchlogic/modifiers/square_root.rb +0 -15
  114. data/lib/searchlogic/modifiers/sum.rb +0 -11
  115. data/lib/searchlogic/modifiers/tan.rb +0 -15
  116. data/lib/searchlogic/modifiers/trim.rb +0 -15
  117. data/lib/searchlogic/modifiers/upper.rb +0 -15
  118. data/lib/searchlogic/modifiers/week.rb +0 -11
  119. data/lib/searchlogic/modifiers/year.rb +0 -11
  120. data/lib/searchlogic/search/base.rb +0 -148
  121. data/lib/searchlogic/search/conditions.rb +0 -53
  122. data/lib/searchlogic/search/ordering.rb +0 -244
  123. data/lib/searchlogic/search/pagination.rb +0 -121
  124. data/lib/searchlogic/search/protection.rb +0 -89
  125. data/lib/searchlogic/search/searching.rb +0 -32
  126. data/lib/searchlogic/shared/utilities.rb +0 -57
  127. data/lib/searchlogic/shared/virtual_classes.rb +0 -39
  128. data/lib/searchlogic/version.rb +0 -79
  129. data/test/active_record_tests/associations_test.rb +0 -94
  130. data/test/active_record_tests/base_test.rb +0 -115
  131. data/test/condition_tests/base_test.rb +0 -62
  132. data/test/condition_tests/begins_with_test.rb +0 -11
  133. data/test/condition_tests/blank_test.rb +0 -31
  134. data/test/condition_tests/child_of_test.rb +0 -17
  135. data/test/condition_tests/descendant_of_test.rb +0 -12
  136. data/test/condition_tests/ends_with_test.rb +0 -11
  137. data/test/condition_tests/equals_test.rb +0 -28
  138. data/test/condition_tests/greater_than_or_equal_to_test.rb +0 -11
  139. data/test/condition_tests/greater_than_test.rb +0 -11
  140. data/test/condition_tests/inclusive_descendant_of_test.rb +0 -12
  141. data/test/condition_tests/keywords_test.rb +0 -23
  142. data/test/condition_tests/less_than_or_equal_to_test.rb +0 -11
  143. data/test/condition_tests/less_than_test.rb +0 -11
  144. data/test/condition_tests/like_test.rb +0 -11
  145. data/test/condition_tests/nil_test.rb +0 -31
  146. data/test/condition_tests/not_begin_with_test.rb +0 -8
  147. data/test/condition_tests/not_blank_test.rb +0 -8
  148. data/test/condition_tests/not_end_with_test.rb +0 -8
  149. data/test/condition_tests/not_equal_test.rb +0 -19
  150. data/test/condition_tests/not_have_keywords_test.rb +0 -8
  151. data/test/condition_tests/not_like_test.rb +0 -8
  152. data/test/condition_tests/not_nil_test.rb +0 -13
  153. data/test/condition_tests/sibling_of_test.rb +0 -15
  154. data/test/conditions_tests/any_or_all_test.rb +0 -23
  155. data/test/conditions_tests/base_test.rb +0 -185
  156. data/test/conditions_tests/groups_test.rb +0 -68
  157. data/test/conditions_tests/magic_methods_test.rb +0 -36
  158. data/test/conditions_tests/multiparameter_attributes_test.rb +0 -15
  159. data/test/conditions_tests/protection_test.rb +0 -18
  160. data/test/config_test.rb +0 -23
  161. data/test/fixtures/accounts.yml +0 -12
  162. data/test/fixtures/animals.yml +0 -7
  163. data/test/fixtures/orders.yml +0 -12
  164. data/test/fixtures/user_groups.yml +0 -5
  165. data/test/fixtures/users.yml +0 -45
  166. data/test/libs/awesome_nested_set.rb +0 -545
  167. data/test/libs/awesome_nested_set/.autotest +0 -13
  168. data/test/libs/awesome_nested_set/compatability.rb +0 -29
  169. data/test/libs/awesome_nested_set/helper.rb +0 -40
  170. data/test/libs/awesome_nested_set/named_scope.rb +0 -140
  171. data/test/libs/rexml_fix.rb +0 -14
  172. data/test/modifier_tests/day_of_month_test.rb +0 -16
  173. data/test/search_tests/base_test.rb +0 -241
  174. data/test/search_tests/conditions_test.rb +0 -21
  175. data/test/search_tests/ordering_test.rb +0 -167
  176. data/test/search_tests/pagination_test.rb +0 -74
  177. data/test/search_tests/protection_test.rb +0 -26
  178. data/test/test_helper.rb +0 -122
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Floor < Base
4
- class << self
5
- def modifier_names
6
- super + ["round_down"]
7
- end
8
-
9
- def return_type
10
- :integer
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Hex < Base
4
- class << self
5
- def return_type
6
- :string
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Hour < Base
4
- class << self
5
- def return_type
6
- :integer
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Log < Base
4
- class << self
5
- def modifier_names
6
- super + ["ln"]
7
- end
8
-
9
- def return_type
10
- :float
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Log10 < Base
4
- class << self
5
- def return_type
6
- :float
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Log2 < Base
4
- class << self
5
- def return_type
6
- :float
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Lower < Base
4
- class << self
5
- def modifier_names
6
- super + ["downcase", "lcase"]
7
- end
8
-
9
- def return_type
10
- :string
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Ltrim < Base
4
- class << self
5
- def modifier_names
6
- super + ["lstrip"]
7
- end
8
-
9
- def return_type
10
- :string
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Md5 < Base
4
- class << self
5
- def return_type
6
- :string
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Microseconds < Base
4
- class << self
5
- def return_type
6
- :integer
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Milliseconds < Base
4
- class << self
5
- def return_type
6
- :integer
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Minute < Base
4
- class << self
5
- def modifier_names
6
- super + ["min"]
7
- end
8
-
9
- def return_type
10
- :integer
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Month < Base
4
- class << self
5
- def modifier_names
6
- super + ["mon"]
7
- end
8
-
9
- def return_type
10
- :integer
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Octal < Base
4
- class << self
5
- def modifier_names
6
- super + ["oct"]
7
- end
8
-
9
- def return_type
10
- :float
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Radians < Base
4
- class << self
5
- def return_type
6
- :float
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Round < Base
4
- class << self
5
- def return_type
6
- :integer
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Rtrim < Base
4
- class << self
5
- def modifier_names
6
- super + ["rstrip"]
7
- end
8
-
9
- def return_type
10
- :string
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Second < Base
4
- class << self
5
- def modifier_names
6
- super + ["sec"]
7
- end
8
-
9
- def return_type
10
- :integer
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Sign < Base
4
- class << self
5
- def return_type
6
- :float
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Sin < Base
4
- class << self
5
- def return_type
6
- :float
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class SquareRoot < Base
4
- class << self
5
- def modifier_names
6
- super + ["sqrt", "sq_rt"]
7
- end
8
-
9
- def return_type
10
- :float
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Sum < Base
4
- class << self
5
- def return_type
6
- :float
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Tan < Base
4
- class << self
5
- def modifier_names
6
- super + ["tangent"]
7
- end
8
-
9
- def return_type
10
- :float
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Trim < Base
4
- class << self
5
- def modifier_names
6
- super + ["strip"]
7
- end
8
-
9
- def return_type
10
- :string
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Upper < Base
4
- class << self
5
- def modifier_names
6
- super + ["upcase", "ucase"]
7
- end
8
-
9
- def return_type
10
- :string
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Week < Base
4
- class << self
5
- def return_type
6
- :integer
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Searchlogic
2
- module Modifiers
3
- class Year < Base
4
- class << self
5
- def return_type
6
- :integer
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,148 +0,0 @@
1
- module Searchlogic #:nodoc:
2
- module Search #:nodoc:
3
- # = Searchlogic
4
- #
5
- # Please refer the README.rdoc for usage, examples, and installation.
6
- class Base
7
- include Searchlogic::Shared::Utilities
8
- include Searchlogic::Shared::VirtualClasses
9
-
10
- # Options ActiveRecord allows when searching
11
- AR_FIND_OPTIONS = ::ActiveRecord::Base.valid_find_options
12
-
13
- # Options ActiveRecord allows when performing calculations
14
- AR_CALCULATIONS_OPTIONS = (::ActiveRecord::Base.valid_calculations_options - [:select, :limit, :offset, :order, :group, :include])
15
-
16
- AR_OPTIONS = (AR_FIND_OPTIONS + AR_CALCULATIONS_OPTIONS).uniq
17
-
18
- # Options that ActiveRecord doesn't suppport, but Searchlogic does
19
- SPECIAL_FIND_OPTIONS = [:order_by, :order_as, :page, :per_page, :priority_order, :priority_order_by, :priority_order_as]
20
-
21
- # Valid options you can use when searching
22
- OPTIONS = SPECIAL_FIND_OPTIONS + AR_OPTIONS # the order is very important, these options get set in this order
23
-
24
- attr_accessor *AR_OPTIONS
25
- attr_writer :scope
26
-
27
- class << self
28
- # Used in the ActiveRecord methods to determine if Searchlogic should get involved or not.
29
- # This keeps Searchlogic out of the way unless it is needed.
30
- def needed?(model_class, options)
31
- return false if options.blank?
32
-
33
- SPECIAL_FIND_OPTIONS.each do |option|
34
- return true if options.symbolize_keys.keys.include?(option)
35
- end
36
-
37
- Searchlogic::Conditions::Base.needed?(model_class, options[:conditions])
38
- end
39
- end
40
-
41
- def initialize(init_options = {})
42
- self.options = init_options
43
- end
44
-
45
- # Flag to determine if searchlogic is acting as a filter for the ActiveRecord search methods.
46
- # By filter it means that searchlogic is being used on the default ActiveRecord search methods, like all, count, find(:all), first, etc.
47
- def acting_as_filter=(value)
48
- @acting_as_filter = value
49
- end
50
-
51
- # See acting_as_filter=
52
- def acting_as_filter?
53
- @acting_as_filter == true
54
- end
55
-
56
- # Specific implementation of cloning
57
- def clone
58
- options = {}
59
- (AR_OPTIONS - [:conditions]).each { |option| options[option] = instance_variable_get("@#{option}") }
60
- options[:conditions] = conditions.conditions
61
- SPECIAL_FIND_OPTIONS.each { |option| options[option] = send(option) }
62
- obj = self.class.new(options)
63
- obj.protect = protected?
64
- obj.scope = scope
65
- obj
66
- end
67
- alias_method :dup, :clone
68
-
69
- # Makes using searchlogic in the console less annoying and keeps the output meaningful and useful
70
- def inspect
71
- current_find_options = {}
72
- (AR_OPTIONS - [:conditions]).each do |option|
73
- value = send(option)
74
- next if value.nil?
75
- current_find_options[option] = value
76
- end
77
- conditions_value = conditions.conditions
78
- current_find_options[:conditions] = conditions_value unless conditions_value.blank?
79
- current_find_options[:scope] = scope unless scope.blank?
80
- "#<#{klass}Search #{current_find_options.inspect}>"
81
- end
82
-
83
- # Merges all joins together, including the scopes joins for
84
- def joins
85
- all_joins = (safe_to_array(conditions.auto_joins) + safe_to_array(order_by_auto_joins) + safe_to_array(priority_order_by_auto_joins) + safe_to_array(@joins)).uniq
86
- all_joins.size <= 1 ? all_joins.first : all_joins
87
- end
88
-
89
- def limit=(value)
90
- @set_limit = true
91
- @limit = value.blank? || value == 0 ? nil : value.to_i
92
- end
93
-
94
- def limit
95
- @limit ||= Config.search.per_page if !acting_as_filter? && !@set_limit
96
- @limit
97
- end
98
-
99
- def offset=(value)
100
- @offset = value.blank? ? nil : value.to_i
101
- end
102
-
103
- def options=(values)
104
- return unless values.is_a?(Hash)
105
- values.symbolize_keys.fast_assert_valid_keys(OPTIONS)
106
- values.each { |key, value| send("#{key}=", value) }
107
- end
108
-
109
- # Sanitizes everything down into options ActiveRecord::Base.find can understand
110
- def sanitize(searching = true)
111
- find_options = {}
112
-
113
- (searching ? AR_FIND_OPTIONS : AR_CALCULATIONS_OPTIONS).each do |find_option|
114
- value = send(find_option)
115
- next if value.blank?
116
- find_options[find_option] = value
117
- end
118
-
119
- find_options
120
- end
121
-
122
- def select
123
- @select ||= "DISTINCT #{klass.connection.quote_table_name(klass.table_name)}.*" if !joins.blank? && Config.search.remove_duplicates? && klass.connection.adapter_name != "PostgreSQL"
124
- @select
125
- end
126
-
127
- def scope
128
- @scope ||= {}
129
- end
130
-
131
- private
132
- def safe_to_array(o)
133
- case o
134
- when NilClass
135
- []
136
- when Array
137
- o
138
- else
139
- [o]
140
- end
141
- end
142
-
143
- def array_of_strings?(o)
144
- o.is_a?(Array) && o.all?{|obj| obj.is_a?(String)}
145
- end
146
- end
147
- end
148
- end