Sha256: 831574f6364901fa207ae31550ec2b185c81c635889ca4fa0c9a479a7cedc126

Contents?: true

Size: 541 Bytes

Versions: 8

Compression:

Stored size: 541 Bytes

Contents

module Protobuf
  module ActiveRecord
    class Transformer
      attr_accessor :callable, :options

      def initialize(callable, options = {})
        @callable = callable
        @options = options
      end

      delegate :call, :to => :callable

      def nullify?(proto)
        return false unless options[:nullify_on]
        return false unless proto.field?(:nullify) && proto.nullify.is_a?(Array)
        return false if proto.nullify.empty?

        proto.nullify.include?(options[:nullify_on].to_s)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
protobuf-activerecord-6.1.0 lib/protobuf/active_record/transformer.rb
protobuf-activerecord-6.0.0 lib/protobuf/active_record/transformer.rb
protobuf-activerecord-5.2.0 lib/protobuf/active_record/transformer.rb
protobuf-activerecord-5.1.0 lib/protobuf/active_record/transformer.rb
protobuf-activerecord-5.0.0 lib/protobuf/active_record/transformer.rb
protobuf-activerecord-5.1.0.beta lib/protobuf/active_record/transformer.rb
protobuf-activerecord-5.0.0.beta lib/protobuf/active_record/transformer.rb
protobuf-activerecord-3.6.1 lib/protobuf/active_record/transformer.rb