Skip to content

Instantly share code, notes, and snippets.

@statonjr
Created March 28, 2013 16:05
Show Gist options
  • Save statonjr/5264434 to your computer and use it in GitHub Desktop.
Save statonjr/5264434 to your computer and use it in GitHub Desktop.
Example repository pattern
module Simple
class Repository
def self.configure(options = {})
@mappings ||= {}
@mappings.merge!(options)
end
def self.reset!
@mappings = {}
end
def self.for(model_class_or_name)
@mappings[model_class_or_name] || @mappings[model_class_or_name.to_s]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment