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