Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update Rails integration

  • Loading branch information...
commit ec29864986499f3e636fadd1b7cfea48ad1b2804 1 parent 01d5991
Matt Mongeau authored
6 lib/presentable.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)
2  presentable.gemspec
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"]
6 rails/init.rb
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")
6 test/presenter_test.rb
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
Please sign in to comment.
Something went wrong with that request. Please try again.