Sha256: c2afd0a2787be356d518dcd9a5fd98def355d3d809bac0c39ea19e57ea5ced78

Contents?: true

Size: 748 Bytes

Versions: 6

Compression:

Stored size: 748 Bytes

Contents

module Representable
  module Feature
    module ReadableWriteable
      def deserialize_property(binding, doc, options)
        return unless binding.writeable?
        super
      end

      def serialize_property(binding, doc, options)
        return unless binding.readable?
        super
      end
    end
  end

  # TODO: i hate monkey-patching Definition here since it globally adds this options. However, for now this should be ok :-)
  class Definition
    # TODO: make this generic like `option :writeable, :default => true`
    def writeable?
      return options[:writeable] if options.has_key?(:writeable)
      true
    end

    def readable?
      return options[:readable] if options.has_key?(:readable)
      true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
representable-1.3.4 lib/representable/readable_writeable.rb
representable-1.3.3 lib/representable/readable_writeable.rb
representable-1.3.2 lib/representable/readable_writeable.rb
representable-1.3.1 lib/representable/readable_writeable.rb
representable-1.3.0 lib/representable/readable_writeable.rb
representable-1.2.9 lib/representable/readable_writeable.rb