Commit ff9130058d63fea9540c1a2a2e0ee3df7797d26c
1 parent
ec19eb0b
Exists in
master
Taking relationship stuff out of the concerns, into the instance
Showing
3 changed files
with
9 additions
and
7 deletions
Show diff stats
lib/surveyable/acts_as_response.rb
@@ -3,14 +3,16 @@ module Surveyable | @@ -3,14 +3,16 @@ module Surveyable | ||
3 | extend ActiveSupport::Concern | 3 | extend ActiveSupport::Concern |
4 | included do | 4 | included do |
5 | has_many :answers, as: :response | 5 | has_many :answers, as: :response |
6 | + def survey | ||
7 | + self.send(survey_relationship) | ||
8 | + end | ||
6 | end | 9 | end |
7 | module ClassMethods | 10 | module ClassMethods |
8 | - def acts_as_response(survey, options = {}) | 11 | + def acts_as_response(survey_relationship, options = {}) |
9 | cattr_accessor :survey | 12 | cattr_accessor :survey |
10 | - self.survey = survey | 13 | + self.survey_relationship = survey_relationship.to_s |
11 | end | 14 | end |
12 | end | 15 | end |
13 | end | 16 | end |
14 | end | 17 | end |
15 | - | ||
16 | ActiveRecord::Base.send :include, Surveyable::ActsAsResponse | 18 | ActiveRecord::Base.send :include, Surveyable::ActsAsResponse |
17 | \ No newline at end of file | 19 | \ No newline at end of file |
lib/surveyable/acts_as_survey.rb
@@ -6,9 +6,9 @@ module Surveyable | @@ -6,9 +6,9 @@ module Surveyable | ||
6 | 6 | ||
7 | end | 7 | end |
8 | module ClassMethods | 8 | module ClassMethods |
9 | - def acts_as_survey(responses, options = {}) | ||
10 | - cattr_accessor :responses | ||
11 | - self.responses = responses | 9 | + def acts_as_survey(response_relationship, options = {}) |
10 | + #cattr_accessor :responses | ||
11 | + #self.responses = responses | ||
12 | end | 12 | end |
13 | end | 13 | end |
14 | end | 14 | end |
lib/surveyable/version.rb