Module: Card::Rule::All
- Included in:
- Card
- Defined in:
- card/lib/card/rule/all.rb
Overview
rule-related Card instance methods
Instance Method Summary collapse
-
#preference(setting_code, user = nil) ⇒ Object
-
#preference? ⇒ Boolean
-
#preference_card(setting_code, user = nil, options = {}) ⇒ Object
-
#preference_card_id(setting_code, user = nil) ⇒ Object
-
#rule(setting_code) ⇒ Object
-
#rule? ⇒ Boolean
-
#rule_card(setting_code, options = {}) ⇒ Object
-
#rule_card_id(setting_code) ⇒ Object
-
#standard_rule? ⇒ Boolean
Instance Method Details
#preference(setting_code, user = nil) ⇒ Object
17 18 19 |
# File 'card/lib/card/rule/all.rb', line 17 def preference setting_code, user=nil preference_card(setting_code, user, skip_modules: true)&.db_content end |
#preference? ⇒ Boolean
42 43 44 45 46 47 |
# File 'card/lib/card/rule/all.rb', line 42 def preference? name.parts.length > 2 && (Card.fetch_type_id(name.right) == SettingID) && (Card.fetch_type_id(name[0..-3]) == SetID) && valid_preferer? end |
#preference_card(setting_code, user = nil, options = {}) ⇒ Object
21 22 23 |
# File 'card/lib/card/rule/all.rb', line 21 def preference_card setting_code, user=nil, ={} Card.fetch preference_card_id(setting_code, user), end |
#preference_card_id(setting_code, user = nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'card/lib/card/rule/all.rb', line 25 def preference_card_id setting_code, user=nil return unless (user_id = preference_user_id user) rule_id_lookup Card::Rule.preference_cache, "#{setting_code}+#{user_id}", "#{setting_code}+#{AllID}" end |
#rule(setting_code) ⇒ Object
5 6 7 |
# File 'card/lib/card/rule/all.rb', line 5 def rule setting_code rule_card(setting_code, skip_modules: true)&.db_content end |
#rule? ⇒ Boolean
33 34 35 |
# File 'card/lib/card/rule/all.rb', line 33 def rule? standard_rule? || preference? end |
#rule_card(setting_code, options = {}) ⇒ Object
9 10 11 |
# File 'card/lib/card/rule/all.rb', line 9 def rule_card setting_code, ={} Card.fetch rule_card_id(setting_code), end |
#rule_card_id(setting_code) ⇒ Object
13 14 15 |
# File 'card/lib/card/rule/all.rb', line 13 def rule_card_id setting_code rule_id_lookup Card::Rule.rule_cache, setting_code end |
#standard_rule? ⇒ Boolean
37 38 39 40 |
# File 'card/lib/card/rule/all.rb', line 37 def standard_rule? (Card.fetch_type_id(name.right) == SettingID) && (Card.fetch_type_id(name.left) == SetID) end |