Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongoid support. #14

Merged
merged 2 commits into from
Jan 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gemspec # Specify your gem's dependencies in phony_number.gemspec
# For testing
gem 'sqlite3'

gem 'rake'
gem 'rspec', '~> 2.11.0'
gem 'guard', '~> 1.2.0'
gem 'guard-bundler', '~> 1.0.0'
Expand Down
37 changes: 19 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
PATH
remote: .
specs:
phony_rails (0.1.10)
activerecord (~> 3.0)
countries (~> 0.8.2)
phony (~> 1.7.7)
phony_rails (0.1.12)
activerecord (>= 3.0)
countries (>= 0.8.2)
phony (>= 1.7.7)

GEM
remote: http://rubygems.org/
specs:
activemodel (3.2.6)
activesupport (= 3.2.6)
activemodel (3.2.10)
activesupport (= 3.2.10)
builder (~> 3.0.0)
activerecord (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activerecord (3.2.10)
activemodel (= 3.2.10)
activesupport (= 3.2.10)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activesupport (3.2.6)
activesupport (3.2.10)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
countries (0.8.2)
currencies (= 0.4.0)
currencies (>= 0.2.0)
builder (3.0.4)
countries (0.8.4)
currencies (>= 0.4.0)
currencies (0.4.0)
diff-lcs (1.1.3)
ffi (1.1.0)
Expand All @@ -37,13 +36,14 @@ GEM
guard (~> 1.1)
guard-rspec (1.2.0)
guard (>= 1.1)
i18n (0.6.0)
i18n (0.6.1)
listen (0.4.7)
rb-fchange (~> 0.0.5)
rb-fsevent (~> 0.9.1)
rb-inotify (~> 0.8.8)
multi_json (1.3.6)
phony (1.7.10)
multi_json (1.5.0)
phony (1.8.4)
rake (10.0.3)
rb-fchange (0.0.5)
ffi
rb-fsevent (0.9.1)
Expand All @@ -59,7 +59,7 @@ GEM
rspec-mocks (2.11.1)
sqlite3 (1.3.6)
thor (0.15.4)
tzinfo (0.3.33)
tzinfo (0.3.35)

PLATFORMS
ruby
Expand All @@ -70,6 +70,7 @@ DEPENDENCIES
guard-bundler (~> 1.0.0)
guard-rspec (~> 1.2.0)
phony_rails!
rake
rb-fsevent
rspec (~> 2.11.0)
sqlite3
4 changes: 4 additions & 0 deletions Rakefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)
task :default => :spec
11 changes: 8 additions & 3 deletions lib/phony_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def self.normalize_number(number, options = {})
number # If all goes wrong .. we still return the original input.
end

# This module is added to AR.
module ActiveRecordExtension
module Extension

def self.extended(base)
base.send :include, InstanceMethods
Expand Down Expand Up @@ -102,7 +101,13 @@ def phony_normalized_method(*attributes)

end

ActiveRecord::Base.extend PhonyRails::ActiveRecordExtension
# check whether it is ActiveRecord or Mongoid being used
ActiveRecord::Base.send :extend, PhonyRails::Extension if defined?(ActiveRecord)
Mongoid::Document.module_eval do
def self.included(base)
base.extend PhonyRails::Extension
end
end if defined?(Mongoid)

Dir["#{File.dirname(__FILE__)}/phony_rails/locales/*.yml"].each do |file|
I18n.load_path << file
Expand Down