Sha256: 80e5c4b220a001dd0e364777cac7f75287a3d662168ccb6c5a5214b8dcd8a15f
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
= lazy_model_const A convenient variant of +lazy_const+ with an eye towards ActiveRecord models. == Installation gem 'lazy_model_const' == Example Here's an example using Rails. Really, any class that has a class method +find_or_create_by_name+ can be used. If you're not using ActiveRecord, you probably want to use the +lazy_const+ gem. app/model/group.rb: class Group < ActiveRecord::Base extend LazyConst lazy_const :EVERYONE, name: 'Everyone' end app/model/user.rb: class User < ActiveRecord::Base has_many :groups after_create :add_to_everyone def add_to_everyone groups << Group.EVERYONE end end == Contributing to lazy_model_const * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it. * Fork the project. * Start a feature/bugfix branch. * Commit and push until you are happy with your contribution. * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. == Copyright Copyright (c) 2013 Ryan Graham. See LICENSE.txt for further details. (TL;DR: MIT license)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lazy_model_const-0.1.1 | README.rdoc |