Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

memoize the presenter class and allow it to be set

  • Loading branch information...
commit e274b53eb37790644efed5d60f9d81011e5f9735 1 parent 4e079f0
@austinthecoder authored
View
4 lib/poser/presentable.rb
@@ -8,8 +8,10 @@ def self.included(base)
end
module ClassMethods
+ attr_writer :presenter_class
+
def presenter_class
- Util.first_available_class(
+ @presenter_class ||= Util.first_available_class(
"#{self}::Presenter",
"#{self}Presenter",
"Poser::Presenter"
View
2  lib/poser/version.rb
@@ -1,3 +1,3 @@
module Poser
- VERSION = "1.0.1"
+ VERSION = "1.0.2"
end
View
9 spec/poser/presentable_spec.rb
@@ -8,10 +8,7 @@
subject { C }
describe "presenter_class" do
- after :all do
- Object.send :remove_const, :CPresenter
- C.send :remove_const, :Presenter
- end
+ before { subject.presenter_class = nil }
it "returns Poser::Presenter when no presenter classes are available for this class" do
subject.presenter_class.should == Poser::Presenter
@@ -20,11 +17,15 @@
it "returns CPresenter if it exists" do
CPresenter = Class.new
subject.presenter_class.should == CPresenter
+ Object.send :remove_const, :CPresenter
end
it "returns the Presenter class namespaced under this class if it exists" do
+ CPresenter = Class.new
C::Presenter = Class.new
subject.presenter_class.should == C::Presenter
+ C.send :remove_const, :Presenter
+ Object.send :remove_const, :CPresenter
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.