module Pragma::Contract::ModelFinder::ClassMethods

Public Instance Methods

property(name, options = {}) click to toggle source
Calls superclass method
# File lib/pragma/contract/model_finder.rb, line 16
def property(name, options = {})
  return super if !options[:type] || options[:type].is_a?(Dry::Types::Type)

  property(name, Hash[options.reject { |k, _| k == :type }])

  define_method("#{name}=") do |value|
    finder = Pragma::Contract::ModelFinder.load_adaptor!(
      options[:type],
      Hash[options.select { |k, _| FINDER_OPTIONS.include?(k.to_sym) }]
    )

    super finder.find(value)
  end
end