Class: CASino::ServiceRule
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CASino::ServiceRule
- Defined in:
- app/models/casino/service_rule.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.allowed?(service_url) ⇒ Boolean
6 7 8 9 10 11 12 13 |
# File 'app/models/casino/service_rule.rb', line 6 def self.allowed?(service_url) rules = self.where(enabled: true) if rules.empty? && !CASino.config.require_service_rules true else rules.any? { |rule| rule.allows?(service_url) } end end |
Instance Method Details
#allows?(service_url) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/casino/service_rule.rb', line 15 def allows?(service_url) if self.regex? regex = Regexp.new self.url, true if regex =~ service_url return true end elsif self.url == service_url return true end false end |