Class: Pragma::Contract::ModelFinder::ActiveRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/pragma/contract/model_finder/active_record.rb

Instance Attribute Summary

Attributes inherited from Base

#klass, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Pragma::Contract::ModelFinder::Base

Class Method Details

.supports?(klass) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/pragma/contract/model_finder/active_record.rb', line 8

def supports?(klass)
  defined?(::ActiveRecord::Base) && klass < ::ActiveRecord::Base
end

Instance Method Details

#find(value) ⇒ Object



13
14
15
# File 'lib/pragma/contract/model_finder/active_record.rb', line 13

def find(value)
  klass.find_by(options[:by] => value)
end