Sha256: af5f505b27d7a8a08276dc9ce76f2051cd12bebfa3f7696c81b32483fa3ede6d

Contents?: true

Size: 736 Bytes

Versions: 6

Compression:

Stored size: 736 Bytes

Contents

module Representable
  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


  # TODO: i hate monkey-patching Definition here since it globally adds this options. However, for now this should be ok :-)
  Definition.class_eval do
    # Checks and returns if the property is writeable
    def writeable?
      return self[:writeable] if self.has_key?(:writeable)
      true
    end

    # Checks and returns if the property is readable
    def readable?
      return self[:readable] if self.has_key?(:readable)
      true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
representable-1.8.5 lib/representable/readable_writeable.rb
representable-1.8.4 lib/representable/readable_writeable.rb
representable-1.8.3 lib/representable/readable_writeable.rb
representable-1.8.2 lib/representable/readable_writeable.rb
representable-1.8.1 lib/representable/readable_writeable.rb
representable-1.8.0 lib/representable/readable_writeable.rb