lib/roaster/adapters/active_record.rb
#TODO: Handle ALL, none should be the default: maybe not ?
# Move resource stuff into resource_for
Handle ALL, none should be the default: maybe not .
Move resource stuff into resource_for
Handle ALL none should be the default : maybe not . Move resource stuff into resource_for
def scope_for(target, model_class_or_name = nil)
        model_class = model_for(model_class_or_name || target.resource_name)
        scope = model_class.all
        unless target.resource_ids.empty?
          scope = scope.where(id: target.resource_ids)
        end
        if target.relationship_name
          raise "Cannot apply relationship #{target.relationship_name} to nil object" if scope.count == 0
          raise "Cannot apply relationship #{target.relationship_name} to more than one object" if scope.count > 1
          scope = scope.first.send(target.relationship_name)
        end
        scope
      end
def scope_for ( target , model_class_or_name = nil ) model_class = model_for ( model_class_or_name || target . resource_name ) scope = model_class . all unless target . resource_ids . empty? scope = scope . where ( id : target . resource_ids ) end if target . relationship_name raise "Cannot apply relationship #{target.relationship_name} to nil object" if scope . count == 0 raise "Cannot apply relationship #{target.relationship_name} to more than one object" if scope . count > 1 scope = scope . first . send ( target . relationship_name ) end scope end
TODO: Handle ALL, none should be the default: maybe not ?
TODO : Handle ALL none should be the default : maybe not ?
target
<not_specific>
model_class_or_name
<not_specific>