Sha256: beb5e90a0227799c41c44c752e9a7b6ea0b7a2527db2a7aec90684fc6a6a6c78
Contents?: true
Size: 813 Bytes
Versions: 1
Compression:
Stored size: 813 Bytes
Contents
module Axel module Associations class HasOne < Base private def included_getter(instance, *args, &block) Array(instance.attributes[relation_name]).map { |attributes| build_klass.new(attributes) }.first end def getter(instance, *args, &block) request_options = args.extract_options! build_klass .querier .without_default_path .at_path(route_path(instance)) .request_options(request_options) .first end def route_path(instance) [URI(instance.request_uri).path, association_path].join("/") end def association_path # needs to be belongs_to, some looks has_many options[:suffix_path].present? && options[:suffix_path] || relation_name.to_s end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axel-0.0.1 | app/models/axel/associations/has_one.rb |