Skip to content

Commit

Permalink
Extract Decorator Step Five
Browse files Browse the repository at this point in the history
* Rename method to follow component API
  • Loading branch information
jferris committed Feb 22, 2013
1 parent 72801b5 commit 61ca678
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example_app/app/models/survey.rb
Expand Up @@ -10,7 +10,7 @@ class Survey < ActiveRecord::Base
def summaries_using(summarizer, options = {})
questions.map do |question|
UnansweredQuestionHider.new(summarizer, options[:answered_by]).
summary_or_hidden_answer(question)
summarize(question)
end
end
end
2 changes: 1 addition & 1 deletion example_app/app/models/unanswered_question_hider.rb
Expand Up @@ -6,7 +6,7 @@ def initialize(summarizer, user)
@user = user
end

def summary_or_hidden_answer(question)
def summarize(question)
if hide_unanswered_question?(question)
hide_answer_to_question(question)
else
Expand Down
8 changes: 4 additions & 4 deletions example_app/spec/models/unanswered_question_hider_spec.rb
@@ -1,13 +1,13 @@
require 'spec_helper'

describe UnansweredQuestionHider, '#summary_or_hidden_answer' do
describe UnansweredQuestionHider, '#summarize' do
it 'returns a hidden summary given a user without an answer' do
summarizer = stub('summarizer')
user = build_stubbed(:user)
question = stub_answered_question(user, false)
hider = UnansweredQuestionHider.new(summarizer, user)

result = hider.summary_or_hidden_answer(question)
result = hider.summarize(question)

result.title.should eq question.title
result.value.should eq UnansweredQuestionHider::NO_ANSWER
Expand All @@ -20,7 +20,7 @@
summarizer = stub_summarizer(question, summary)
hider = UnansweredQuestionHider.new(summarizer, user)

result = hider.summary_or_hidden_answer(question)
result = hider.summarize(question)

result.should eq summary
end
Expand All @@ -31,7 +31,7 @@
summarizer = stub_summarizer(question, summary)
hider = UnansweredQuestionHider.new(summarizer, nil)

result = hider.summary_or_hidden_answer(question)
result = hider.summarize(question)

result.should eq summary
end
Expand Down

0 comments on commit 61ca678

Please sign in to comment.