1
0

instance.rb 604 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. class Instance
  3. include ActiveModel::Model
  4. attr_accessor :domain, :accounts_count, :domain_block
  5. def initialize(resource)
  6. @domain = resource.domain
  7. @accounts_count = resource.respond_to?(:accounts_count) ? resource.accounts_count : nil
  8. @domain_block = resource.is_a?(DomainBlock) ? resource : DomainBlock.rule_for(domain)
  9. @domain_allow = resource.is_a?(DomainAllow) ? resource : DomainAllow.rule_for(domain)
  10. end
  11. def countable?
  12. @accounts_count.present?
  13. end
  14. def to_param
  15. domain
  16. end
  17. def cache_key
  18. domain
  19. end
  20. end