Skip to content

Instantly share code, notes, and snippets.

@knewter
Created September 8, 2012 01:10
Show Gist options
  • Save knewter/3671084 to your computer and use it in GitHub Desktop.
Save knewter/3671084 to your computer and use it in GitHub Desktop.
MacroReflection-esque ActiveRecord::Relation does what now?
class MacroReflectionRelationFacade < SimpleDelegator
def initialize(proxied)
super(proxied)
end
def target
self
end
end
require 'macro_reflection_relation_facade'
class Person < ActiveRecord::Base
has_many :person_school_links
# Relationships
def person_school_links(status = :status_active)
MacroReflectionRelationFacade.new(PersonSchoolLink.where(person_id: self.id).send(status))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment