Module: SmoothOperator::Operator::HelperMethods
Instance Method Summary collapse
- #get_me_an_operator(options) ⇒ Object
- #populate_options(object, options) ⇒ Object
- #strip_params(object, http_verb, data) ⇒ Object
Instance Method Details
#get_me_an_operator(options) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/smooth_operator/operator.rb', line 111 def get_me_an_operator() if [:parallel_connection].nil? Operators::Faraday else [:connection] = .delete(:parallel_connection) Operators::Typhoeus end end |
#populate_options(object, options) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/smooth_operator/operator.rb', line 120 def (object, ) ||= {} ClassMethods::OPTIONS.each do |option, default| [option] ||= object.send(option) end [:headers] = object.headers.merge([:headers] || {}) parent_object = [:parent_object] if !parent_object.nil? && [:ignore_parent] != true id = Helpers.primary_key(parent_object) id = "#{id}/" if Helpers.present?(id) [:resources_name] ||= "#{parent_object.class.resources_name}/#{id}#{object.resources_name}" end end |
#strip_params(object, http_verb, data) ⇒ Object
142 143 144 145 146 147 148 149 150 |
# File 'lib/smooth_operator/operator.rb', line 142 def strip_params(object, http_verb, data) data ||= {} if [:get, :head, :delete].include?(http_verb) [object.query_string(data), nil] else [object.query_string({}), data] end end |