class Deadwood::Katello::Base
Public Class Methods
collection_path(prefix_options = {}, query_options = nil)
click to toggle source
# File lib/deadwood/model/base.rb, line 32 def collection_path(prefix_options = {}, query_options = nil) prefix_options, query_options = split_options(prefix_options) if query_options.nil? "#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}" end
config()
click to toggle source
# File lib/deadwood/model/base.rb, line 57 def config @@config end
config=(conf={})
click to toggle source
# File lib/deadwood/model/base.rb, line 61 def config=(conf={}) @@config = conf self.site = @@config[:site] end
element_path(id, prefix_options = {}, query_options = nil)
click to toggle source
# File lib/deadwood/model/base.rb, line 27 def element_path(id, prefix_options = {}, query_options = nil) prefix_options, query_options = split_options(prefix_options) if query_options.nil? "#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}" end
get(method_name, options = {})
click to toggle source
# File lib/deadwood/model/base.rb, line 48 def get(method_name, options = {}) object_array = connection.get(custom_method_collection_url(method_name, options), headers) if object_array.class.to_s=="Array" object_array.collect! {|record| self.class.new.load(record)} else self.class.new.load(object_array) end end
instantiate_collection(collection, prefix_options = {})
click to toggle source
# File lib/deadwood/model/base.rb, line 37 def instantiate_collection(collection, prefix_options = {}) if collection.kind_of? Array collection.collect! { |record| instantiate_record(record, prefix_options) } elsif collection.kind_of? String collection else [instantiate_record(collection, prefix_options)] end rescue ArgumentError end
use_oauth?()
click to toggle source
# File lib/deadwood/model/base.rb, line 66 def use_oauth? config[:consumer_key] && config[:consumer_secret] && config[:site] end
Public Instance Methods
collection_path(prefix_options = {}, query_options = nil)
click to toggle source
# File lib/deadwood/model/base.rb, line 78 def collection_path(prefix_options = {}, query_options = nil) prefix_options, query_options = split_options(prefix_options) if query_options.nil? query_options.merge!(self.attributes) "#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}" end
load_attributes_from_response(response)
click to toggle source
# File lib/deadwood/model/base.rb, line 71 def load_attributes_from_response(response) if response['Content-Length'] != "0" && response.body.strip.size > 0 load(self.class.format.decode(response.body)) end rescue ArgumentError end
query_string(options)
click to toggle source
# File lib/deadwood/model/base.rb, line 84 def query_string(options) "?#{options.to_query}" unless options.nil? || options.empty? end