mod/settings/lib/card/setting.rb in card-1.92.2 vs mod/settings/lib/card/setting.rb in card-1.93.0

- old
+ new

@@ -32,14 +32,10 @@ def self.user_specific? codename @@user_specific.include? codename end - def to_type_id type - type.is_a?(Integer) ? type : Card::Codename[type] - end - # usage: # setting_opts group: :permission | :event | ... # position: <Fixnum> (starting at 1, default: add to end) # rule_type_editable: true | false (default: false) # restricted_to_type: <cardtype> | [ <cardtype>, ...] @@ -49,17 +45,11 @@ set_position group, opts[:position] @codename = opts[:codename] || name.match(/::(\w+)$/)[1].underscore.to_sym self.rule_type_editable = opts[:rule_type_editable] - self.restricted_to_type = - if opts[:restricted_to_type] - type_ids = [opts[:restricted_to_type]].flatten.map do |cardtype| - to_type_id(cardtype) - end - ::Set.new(type_ids) - end + self.restricted_to_type = permitted_type_ids opts[:restricted_to_type] return unless opts[:user_specific] @@user_specific << @codename end def set_position group, pos @@ -74,8 +64,18 @@ end end def applies_to_cardtype type_id !restricted_to_type || restricted_to_type.include?(type_id) + end + + private + + def permitted_type_ids types + return unless types + type_ids = Array.wrap(types).flatten.map do |cardtype| + Card::Codename.id cardtype + end + ::Set.new(type_ids) end end end