ref: no more need block config
parent
ce7802072e
commit
6d71dccb2d
|
@ -1,15 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Rating
|
module Rating
|
||||||
class << self
|
|
||||||
def config
|
|
||||||
@config ||= Config.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def configure
|
|
||||||
yield config
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'rating/config'
|
require 'rating/config'
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Rating
|
module Rating
|
||||||
class Config
|
module Config
|
||||||
|
module_function
|
||||||
|
|
||||||
def config
|
def config
|
||||||
@config ||= begin
|
@config ||= begin
|
||||||
file_path = File.expand_path('config/rating.yml')
|
file_path = File.expand_path('config/rating.yml')
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
module Rating
|
module Rating
|
||||||
class Rate < ActiveRecord::Base
|
class Rate < ActiveRecord::Base
|
||||||
self.table_name_prefix = 'rating_'
|
self.table_name_prefix = 'rating_'
|
||||||
self.table_name = ::Rating.config.rate_table
|
self.table_name = ::Rating::Config.rate_table
|
||||||
|
|
||||||
after_save :update_rating
|
after_save :update_rating
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
module Rating
|
module Rating
|
||||||
class Rating < ActiveRecord::Base
|
class Rating < ActiveRecord::Base
|
||||||
self.table_name_prefix = 'rating_'
|
self.table_name_prefix = 'rating_'
|
||||||
self.table_name = ::Rating.config.rating_table
|
self.table_name = ::Rating::Config.rating_table
|
||||||
|
|
||||||
belongs_to :resource, polymorphic: true
|
belongs_to :resource, polymorphic: true
|
||||||
belongs_to :scopeable, polymorphic: true
|
belongs_to :scopeable, polymorphic: true
|
||||||
|
|
Loading…
Reference in New Issue