Sha256: c896ebeacb861098e836bf7a398a7e291dcc3a2b26a35f9f7bb5dc8033cfe5ea

Contents?: true

Size: 1.36 KB

Versions: 9

Compression:

Stored size: 1.36 KB

Contents

module RedboothRuby
  module Operations
    module Meta
      # Returns a hash with the object metadata
      #
      # @return [Hash] the object metadata
      def metadata
        response = RedboothRuby.request(:get, nil, 'metadata',
                                        { target_id: id, target_type: klass_name },
                                        { session: session })
        response.data
      end

      # Sets the given hash as the desired metadata
      #
      # @return [Hash] the object metadata
      def metadata=(hash)
        response = RedboothRuby.request(:post, nil, 'metadata',
                                        { target_id: id, target_type: klass_name, metadata: hash },
                                        { session: session })

        response.data
      end

      # Merges the given hash with the exiting metadata and set the result
      #
      # @return [Hash] the object metadata
      def metadata_merge(hash)
        response = RedboothRuby.request(:put, nil, 'metadata',
                                        { target_id: id, target_type: klass_name, metadata: hash },
                                        { session: session })

        response.data
      end

      protected

      # Return redbooth class name
      #
      # @return [String]
      def klass_name
        self.class.to_s.split('::').last
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
redbooth-ruby-0.2.3 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.2.2 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.2.1 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.2.0 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.1.4 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.1.3 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.1.1 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.1.0 lib/redbooth-ruby/operations/meta.rb
redbooth-ruby-0.0.5 lib/redbooth-ruby/operations/meta.rb