lib/roaster/request.rb
#TODO: Move/fix this (mapping should expose some clean way to inspect relationships) !
Move/fix this (mapping should expose some clean way to inspect relationships) !
Move / fix this ( mapping should expose some clean way to inspect relationships ) !
def resolve_relationships(rels)
      Hash[rels.map do |name, v|
        rname = [:_has_one, :_has_many].map do |k|
          ra = @resource_mapping_class.representable_attrs[k]
          next nil unless ra
          r = ra.find {|r| r[:as].to_sym == name.to_sym }
          r ? r[:name] : nil
        end.compact.first
        raise "Unknown rel: #{name}" unless rname
        [rname, v]
      end]
    end
def resolve_relationships ( rels ) Hash [ rels . map do | name , v | rname = [ :_has_one , :_has_many ] . map do | k | ra = @resource_mapping_class . representable_attrs [ k ] next nil unless ra r = ra . find { | r | r [ :as ] . to_sym == name . to_sym } r ? r [ :name ] : nil end . compact . first raise "Unknown rel: #{name}" unless rname [ rname , v ] end ] end
TODO: Move/fix this (mapping should expose some clean way to inspect relationships) !
TODO : Move / fix this ( mapping should expose some clean way to inspect relationships ) !
rels
<not_specific>