Skip to content

Commit

Permalink
refactored omniturize method
Browse files Browse the repository at this point in the history
  • Loading branch information
eLafo committed Oct 26, 2011
1 parent 0e00a98 commit 5091ce7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/omniturize_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.included(base)
module ClassMethods
def omniturize(options = {})
include InstanceMethods
before_filter :set_reporter, options
before_filter{|c| c.send(:set_reporter, options.reverse_merge(:reporter => c.class.name.gsub(/Controller$/, '')))}
attr_accessor :reporter
end
end
Expand All @@ -18,10 +18,8 @@ module InstanceMethods
private

def set_reporter(options = {})

@reporter ||= begin
options[:controller].present? ? "#{options[:controller].classify}Reporter".constantize.new(self) :
"#{self.class.name.gsub(/Controller$/, '')}Reporter".constantize.new(self)
"#{options[:reporter].classify.pluralize}Reporter".constantize.new(self)
rescue NameError
BasicReporter.new(self)
end
Expand Down

0 comments on commit 5091ce7

Please sign in to comment.