ref: no more need block config

main
Washington Botelho 2018-02-14 14:46:51 -02:00
parent ce7802072e
commit 6d71dccb2d
No known key found for this signature in database
GPG Key ID: 5DE4F42A8F073617
4 changed files with 5 additions and 12 deletions

View File

@ -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'

View File

@ -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')

View File

@ -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

View File

@ -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