Commit e0483543337f7826e48d593550f2586f27946513
1 parent
0c649c66
Exists in
master
Moving away from concerns setup to model setup
Showing
2 changed files
with
5 additions
and
8 deletions
Show diff stats
lib/surveyable/acts_as_survey.rb
1 | module Surveyable | 1 | module Surveyable |
2 | module ActsAsSurvey | 2 | module ActsAsSurvey |
3 | - extend ActiveSupport::Concern | ||
4 | - included do | ||
5 | - has_many :questions, as: :survey, class_name: 'Surveyable::Question' | ||
6 | - | 3 | + def self.included(base) |
4 | + base.send :extend, ClassMethods | ||
7 | end | 5 | end |
8 | module ClassMethods | 6 | module ClassMethods |
9 | def acts_as_survey(response_relationship, options = {}) | 7 | def acts_as_survey(response_relationship, options = {}) |
8 | + has_many :questions, as: :survey, class_name: 'Surveyable::Question' | ||
10 | #cattr_accessor :responses | 9 | #cattr_accessor :responses |
11 | #self.responses = responses | 10 | #self.responses = responses |
12 | end | 11 | end |
13 | end | 12 | end |
14 | end | 13 | end |
15 | -end | ||
16 | - | ||
17 | -ActiveRecord::Base.extend(Surveyable::ActsAsSurvey) | ||
18 | \ No newline at end of file | 14 | \ No newline at end of file |
15 | +end | ||
19 | \ No newline at end of file | 16 | \ No newline at end of file |
lib/surveyable/version.rb