Method: OldApiResource::Base.site=

Defined in:
lib/old_api_resource/base.rb

.site=(site) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/old_api_resource/base.rb', line 83

def site=(site)
  # store so we can reload attributes if the site changed
  old_site = self.site.to_s.clone
  @connection = nil
  
  if site.nil?
    write_inheritable_attribute(:site, nil)
    # no site, so we'll skip the reload
    return site
  else
    write_inheritable_attribute(:site, create_site_uri_from(site))
  end
  
  # reset class attributes and try to reload them if the site changed
  unless self.site.to_s == old_site
    self.reload_class_attributes
  end
  
  return site
end