From 6d71dccb2d51208b78e916f1c9628fa775d3632d Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Wed, 14 Feb 2018 14:46:51 -0200 Subject: [PATCH] ref: no more need block config --- lib/rating.rb | 9 --------- lib/rating/config.rb | 4 +++- lib/rating/models/rating/rate.rb | 2 +- lib/rating/models/rating/rating.rb | 2 +- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/rating.rb b/lib/rating.rb index 09b8a6c..cbd22fa 100644 --- a/lib/rating.rb +++ b/lib/rating.rb @@ -1,15 +1,6 @@ # frozen_string_literal: true module Rating - class << self - def config - @config ||= Config.new - end - - def configure - yield config - end - end end require 'rating/config' diff --git a/lib/rating/config.rb b/lib/rating/config.rb index 172b793..facdefa 100644 --- a/lib/rating/config.rb +++ b/lib/rating/config.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true module Rating - class Config + module Config + module_function + def config @config ||= begin file_path = File.expand_path('config/rating.yml') diff --git a/lib/rating/models/rating/rate.rb b/lib/rating/models/rating/rate.rb index 9cc98f1..d7bbf75 100644 --- a/lib/rating/models/rating/rate.rb +++ b/lib/rating/models/rating/rate.rb @@ -3,7 +3,7 @@ module Rating class Rate < ActiveRecord::Base self.table_name_prefix = 'rating_' - self.table_name = ::Rating.config.rate_table + self.table_name = ::Rating::Config.rate_table after_save :update_rating diff --git a/lib/rating/models/rating/rating.rb b/lib/rating/models/rating/rating.rb index 23e55d4..35c3c55 100644 --- a/lib/rating/models/rating/rating.rb +++ b/lib/rating/models/rating/rating.rb @@ -3,7 +3,7 @@ module Rating class Rating < ActiveRecord::Base 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 :scopeable, polymorphic: true