Permalink
Browse files

Update Rails integration

  • Loading branch information...
1 parent 01d5991 commit ec29864986499f3e636fadd1b7cfea48ad1b2804 Matt Mongeau committed Dec 17, 2009
Showing with 8 additions and 12 deletions.
  1. +5 −1 lib/presentable.rb
  2. +1 −1 presentable.gemspec
  3. +1 −5 rails/init.rb
  4. +1 −5 test/presenter_test.rb
View
@@ -4,6 +4,7 @@
module Presentable
attr_accessor :presenter_name, :presenter
+
def presenter_name
@presenter_name ||= self.class.to_s + 'Presenter'
end
@@ -27,4 +28,7 @@ def presenter
CollectionPresenter.new(self)
end
end
-end
+end
+
+Object.send(:include, Presentable)
+Array.send(:include, Presentable::Collection)
View
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{presentable}
- s.version = "0.1.1"
+ s.version = "0.1.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["toastyapps"]
View
@@ -1,6 +1,2 @@
require 'presentable'
-
-ActiveRecord::Base.send(:include, Presentable) if defined? ActiveRecord
-Presentable.send(:include, ActionView::Helpers) if defined? ActionView
-
-Array.send(:include, Presentable::Collection)
+Presenter.send(:include, ActionView::Helpers) if Object.const_get("ActionView")
View
@@ -1,7 +1,5 @@
require 'test_helper'
-require 'test_helper'
-
class PresenterTest < Test::Unit::TestCase
def test_presenter
post = Post.new.presenter
@@ -25,10 +23,8 @@ def test_presenter_naming
def test_class
- post = Post.new.presenter
+ post, rss = Post.new.presenter, RssPresenter.new
assert_equal Post, post.class
- rss = RssPresenter.new
- puts rss.methods.sort.inspect
assert_equal RssPresenter, rss.class
end
end

0 comments on commit ec29864

Please sign in to comment.