class Rsbe::Client::Partner
Class simplifies interaction with RSBE Partner
resources
Public Class Methods
all_attrs()
click to toggle source
# File lib/rsbe/client/partner.rb, line 26 def self.all_attrs rw_attrs + ro_attrs end
base_path()
click to toggle source
Calls superclass method
Rsbe::Client::Base::base_path
# File lib/rsbe/client/partner.rb, line 7 def self.base_path super + '/partners' end
new(vals = {})
click to toggle source
Calls superclass method
Rsbe::Client::Base::new
# File lib/rsbe/client/partner.rb, line 64 def initialize(vals = {}) fail(ArgumentError, 'Constructor requires a Hash') unless vals.is_a?(Hash) super() @hash = {} @response = nil # initialize local hash with incoming values, restrict to RW attrs self.class.rw_attrs.each { |x| @hash[x] = (vals[x] || vals[x.to_s]) } end
ro_attrs()
click to toggle source
# File lib/rsbe/client/partner.rb, line 22 def self.ro_attrs [:created_at, :updated_at, :lock_version] end
rw_attrs()
click to toggle source
implementation objectives:
-
expose attributes via standard setter/getter methods
-
create getters for all Read-Only (RO) attributes
-
create setters only for Read/Write (RW) attributes
-
use hash for internal representation to simplify passing data back and forth to back end app
# File lib/rsbe/client/partner.rb, line 18 def self.rw_attrs [:id, :code, :name, :rel_path] end
Public Instance Methods
collections()
click to toggle source
# File lib/rsbe/client/partner.rb, line 74 def collections fail 'Error getting collections' unless get_children('colls') JSON.parse(@response.body).collect do |json_hash| Rsbe::Client::Collection.new(json_hash) end end