Skip to content

Commit

Permalink
Add method that delegates calls to presenter to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
blaknite committed May 18, 2016
1 parent a39a258 commit d4a5d70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/blush/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module Blush
class Configuration
attr_accessor :accessor_name
attr_accessor :accessor_name, :helper_name

def initialize
@accessor_name = :presenter
@helper_name = :present
end
end
end
4 changes: 4 additions & 0 deletions lib/blush/has_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def has_presenter(accessor_name = {}, options = nil)
define_method(accessor_name || Blush.config.accessor_name) do
@presenter ||= (self.blush_options[:class] || "#{self.model_name}Presenter".constantize).new(self)
end

define_method(self.blush_options[:helper_name] || Blush.config.helper_name) do |method, *args, &block|
presenter.try(method, *args, &block) || send(method, *args, &block)
end
end
end
end

0 comments on commit d4a5d70

Please sign in to comment.