Skip to content
Browse files

Adding extensions to ActiveRecord::Base, for now it's just a stupid c…

…lass method that returns true as a proof of concept
  • Loading branch information...
1 parent b6ef8ee commit e707bf83f2c09eac492051a2e5b3933f7929aa46 @Intrepidd committed Mar 31, 2012
Showing with 24 additions and 6 deletions.
  1. +4 −4 lib/rails-canhaz.rb
  2. +15 −0 lib/rails-canhaz/model_extensions.rb
  3. +5 −2 rails-canhaz.gemspec
View
8 lib/rails-canhaz.rb
@@ -1,5 +1,5 @@
-class CanHaz
- def self.hi
- puts "Hello world, this is WIP :)"
- end
+require 'rails-canhaz/model_extensions'
+
+if defined? ActiveRecord::Base
+ ActiveRecord::Base.send(:include, CanHaz::ModelExtensions)
end
View
15 lib/rails-canhaz/model_extensions.rb
@@ -0,0 +1,15 @@
+module CanHaz
+ module ModelExtensions
+ def self.included(base)
+ base.send(:extend, ClassMethods)
+ end
+ end
+
+ module ClassMethods
+
+ def CanHaz
+ true
+ end
+
+ end
+end
View
7 rails-canhaz.gemspec
@@ -6,7 +6,10 @@ Gem::Specification.new do |s|
s.description = "A simple gem for managing permissions between rails models"
s.authors = ["Adrien Siami (Intrepidd)"]
s.email = 'adrien@siami.fr'
- s.files = ["lib/rails-canhaz.rb"]
+ s.files = [
+ "lib/rails-canhaz.rb",
+ "lib/rails-canhaz/model_extensions.rb"
+ ]
s.homepage =
- 'http://rubygems.org/gems/rails-canhaz'
+ 'http://github.com/Intrepidd/rails-canhaz'
end

0 comments on commit e707bf8

Please sign in to comment.
Something went wrong with that request. Please try again.