Use ActiveSupport::Concern for included modules
parent
6257d03e45
commit
31090e74cc
|
@ -1,7 +1,14 @@
|
||||||
|
require 'active_support/concern'
|
||||||
|
|
||||||
module TheModerator
|
module TheModerator
|
||||||
module Model
|
module Model
|
||||||
def self.included(base)
|
extend ActiveSupport::Concern
|
||||||
base.has_many :moderations, as: :moderatable, dependent: :destroy
|
|
||||||
|
included do
|
||||||
|
has_many :moderations, as: :moderatable, dependent: :destroy
|
||||||
|
end
|
||||||
|
|
||||||
|
module ClassMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderate(*moderated_attributes)
|
def moderate(*moderated_attributes)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
require 'active_support/concern'
|
||||||
|
|
||||||
module TheModerator
|
module TheModerator
|
||||||
module ModerationModel
|
module ModerationModel
|
||||||
def self.included(base)
|
extend ActiveSupport::Concern
|
||||||
base.send :extend, ClassMethods
|
|
||||||
|
|
||||||
base.class_eval do
|
included do
|
||||||
belongs_to :moderatable, polymorphic: true
|
belongs_to :moderatable, polymorphic: true
|
||||||
serialize :data
|
serialize :data
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
||||||
|
|
||||||
spec.add_dependency "activemodel", "~> 3.2.0"
|
spec.add_dependency "activemodel", "~> 3.2.0"
|
||||||
spec.add_dependency "activerecord", "~> 3.2.0"
|
spec.add_dependency "activerecord", "~> 3.2.0"
|
||||||
|
spec.add_dependency "activesupport", "~> 3.2.0"
|
||||||
|
|
||||||
spec.add_development_dependency "bundler", "~> 1.3"
|
spec.add_development_dependency "bundler", "~> 1.3"
|
||||||
spec.add_development_dependency "rake"
|
spec.add_development_dependency "rake"
|
||||||
|
|
Loading…
Reference in New Issue