Sha256: b68def599fe31d1a5fc10e3ee97ee54babd5c460dfd8aaf2b619797879cabdff
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
module CanCan module ModelAdapters class AbstractAdapter def self.inherited(subclass) @subclasses ||= [] @subclasses << subclass end def self.adapter_class(model_class) @subclasses.detect { |subclass| subclass.for_class?(model_class) } || DefaultAdapter end # Used to determine if the given adapter should be used for the passed in class. def self.for_class?(member_class) false # override in subclass end # Used to determine if this model adapter will override the matching behavior for a hash of conditions. # If this returns true then matches_conditions_hash? will be called. See Rule#matches_conditions_hash def self.override_conditions_hash_matching?(subject, conditions) false end # Override if override_conditions_hash_matching? returns true def self.matches_conditions_hash?(subject, conditions) raise NotImplemented, "This model adapter does not support matching on a conditions hash." end def initialize(model_class, rules) @model_class = model_class @rules = rules end def database_records # This should be overridden in a subclass to return records which match @rules raise NotImplemented, "This model adapter does not support fetching records from the database." end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cancan-1.5.1 | lib/cancan/model_adapters/abstract_adapter.rb |
cancan-1.5.0 | lib/cancan/model_adapters/abstract_adapter.rb |
cancan-1.5.0.beta1 | lib/cancan/model_adapters/abstract_adapter.rb |