lib/shogun/presenter.rb in shogun-3.4.0 vs lib/shogun/presenter.rb in shogun-4.0.0
- old
+ new
@@ -14,17 +14,21 @@
def meta
@meta
end
- def linked
- @linked
- end
-
def links
@links.tap do |hash|
includes.each do |name|
+ hash.store(name, [host, name, "?#{name}=#{id}"].join("/"))
+ end
+ end
+ end
+
+ def linked
+ @linked.tap do |hash|
+ includes.each do |name|
case association(name).macro
when :has_many
hash.store(name, source.public_send(name).pluck(:id))
when :belongs_to
hash.store(name, source.public_send(association(name).foreign_key))
@@ -34,18 +38,22 @@
end
end
end
private def host
- ENV["API_HOST"]
+ ENV["SERVER_HOST"]
end
private def namespace
self.class.const_get("NAMESPACE")
end
private def association(name)
- source.class.reflections[name.to_sym]
+ associations[name.to_sym]
+ end
+
+ private def associations
+ source.class.reflections
end
private def source
@source
end