module DaisybillApi::Ext::Links::InstanceMethods
Public Class Methods
new(attributes)
click to toggle source
Calls superclass method
# File lib/daisybill_api/ext/links.rb, line 21 def initialize(attributes) lnks = attributes.delete "links" super(attributes) class_links.each { |link| links[link.name] = link.clone } self.links = lnks end
Public Instance Methods
links=(values)
click to toggle source
# File lib/daisybill_api/ext/links.rb, line 28 def links=(values) return if values.nil? values.each { |link| write_link link["rel"], link["href"] } end
Private Instance Methods
class_links()
click to toggle source
# File lib/daisybill_api/ext/links.rb, line 48 def class_links @class_links ||= self.class.links.values end
links()
click to toggle source
# File lib/daisybill_api/ext/links.rb, line 52 def links @links ||= {} end
read_link(name)
click to toggle source
# File lib/daisybill_api/ext/links.rb, line 35 def read_link(name) links[name] end
write_link(name, href)
click to toggle source
# File lib/daisybill_api/ext/links.rb, line 39 def write_link(name, href) if link = links[name.to_sym] link.href = href self.send("#{link.foreign_key}=", link.foreign_id) if href && link.foreign_key? else DaisybillApi.logger.debug "Was trying to set unexisting link #{name.inspect} with #{href.inspect}" end end