Module: Rating::Config
- Defined in:
- lib/rating/config.rb
Class Method Summary collapse
- .config ⇒ Object
- .rate_table ⇒ Object
- .rating_levels ⇒ Object
- .rating_table ⇒ Object
- .rating_z_score ⇒ Object
- .validations ⇒ Object
Class Method Details
.config ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/rating/config.rb', line 7 def config @config ||= begin file_path = File.('config/rating.yml') File.exist?(file_path) ? YAML.safe_load_file(file_path)['rating'] : {} end end |
.rate_table ⇒ Object
15 16 17 |
# File 'lib/rating/config.rb', line 15 def rate_table @rate_table ||= config[__method__.to_s] || 'rating_rates' end |
.rating_levels ⇒ Object
23 24 25 |
# File 'lib/rating/config.rb', line 23 def @rating_levels ||= config[__method__.to_s] || 5 end |
.rating_table ⇒ Object
19 20 21 |
# File 'lib/rating/config.rb', line 19 def @rating_table ||= config[__method__.to_s] || 'rating_ratings' end |
.rating_z_score ⇒ Object
27 28 29 |
# File 'lib/rating/config.rb', line 27 def @rating_z_score ||= config[__method__.to_s] || 1.96 end |
.validations ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rating/config.rb', line 31 def validations @validations ||= begin default_scope = %w[author_type resource_id resource_type scopeable_id scopeable_type] { rate: { case_sensitive: config.dig('validations', 'rate', 'case_sensitive') || false, scope: config.dig('validations', 'rate', 'scope') || default_scope, }, }.deep_stringify_keys end end |