class ActiveValidation::OrmPlugins::ActiveRecordPlugin::Adapter
Public Class Methods
new()
click to toggle source
# File lib/active_validation/orm_plugins/active_record_plugin/adapter.rb, line 12 def initialize setup unless self.class.initialised self.class.initialised = true end
Public Instance Methods
add_manifest(manifest)
click to toggle source
@see BaseAdapter
# File lib/active_validation/orm_plugins/active_record_plugin/adapter.rb, line 25 def add_manifest(manifest) Manifest.create manifest.as_json(checks: { only: %i[type argument options], as: :checks_attributes }) manifest end
find_manifest(wheres)
click to toggle source
@see BaseAdapter
# File lib/active_validation/orm_plugins/active_record_plugin/adapter.rb, line 36 def find_manifest(wheres) search(wheres, &:first!) end
find_manifests(wheres)
click to toggle source
@see BaseAdapter
# File lib/active_validation/orm_plugins/active_record_plugin/adapter.rb, line 31 def find_manifests(wheres) search(wheres) end
setup()
click to toggle source
@return [true]
# File lib/active_validation/orm_plugins/active_record_plugin/adapter.rb, line 18 def setup return installer if defined?(::ActiveRecord::Base) ::ActiveSupport.on_load(:active_record_adapter, &method(:installer)) end
Private Instance Methods
installer()
click to toggle source
@return [true]
# File lib/active_validation/orm_plugins/active_record_plugin/adapter.rb, line 50 def installer ActiveValidation::OrmPlugins::ActiveRecordPlugin::Adapter.loader ActiveValidation::Internal::Models::Check.include(ActiveValidation::InternalModelExtensions::Check) ::ActiveRecord::Base.include ActiveValidation::ActiveRecordModelExtension true end
search(wheres) { |relation| ... }
click to toggle source
@api internal
# File lib/active_validation/orm_plugins/active_record_plugin/adapter.rb, line 43 def search(wheres) relation = Manifest.includes(:checks).where(wheres).order(created_at: :desc, id: :desc) relation = yield relation if block_given? relation.is_a?(ActiveRecord::Base) ? relation.to_internal_manifest : relation.map(&:to_internal_manifest) end