Sha256: 6cf44e722101a0e580c2b179d109bc24cf75248b58a36b58544dceb31a765247
Contents?: true
Size: 796 Bytes
Versions: 22
Compression:
Stored size: 796 Bytes
Contents
module Zendesk2::Attributes def assoc_reader(name, options={}) assoc_key = options[:key] || "#{name}_id" collection = options[:collection] || "#{name}s" define_method(name) do if assoc_id = self.send(assoc_key) self.service.send(collection).get(assoc_id) else self.instance_variable_get("@#{name}") end end end def assoc_writer(name, options={}) assoc_key = options[:key] || "#{name}_id" define_method("#{name}=") do |assoc| if assoc.is_a?(Cistern::Model) self.send("#{assoc_key}=", assoc.identity) else self.instance_variable_set("@#{name}", assoc) end end end def assoc_accessor(name, options={}) assoc_reader(name, options) assoc_writer(name, options) end # TODO: collection end
Version data entries
22 entries across 22 versions & 1 rubygems