Sha256: b6914444e910b6394f35ef22463b4637adbc6fb54be2e6d05745821cc1d7615c

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

module Yaks
  class NullResource < Resource
    include attributes.add(collection: false),
            Equalizer.new(:rels, :collection)

    def initialize(opts = {})
      _opts = {}
      _opts[:rels]       = opts[:rels]       if opts.key?(:rels)
      _opts[:collection] = opts[:collection] if opts.key?(:collection)
      super(_opts)
    end

    def each
      to_enum
    end

    def collection?
      @collection
    end

    def null_resource?
      true
    end

    def seq
      []
    end

    def map
      return [] if collection?
      raise UnsupportedOperationError, "Operation #{__method__} not supported on #{self.class}"
    end

    def update_attributes(_new_attrs)
      raise UnsupportedOperationError, "Operation #{__method__} not supported on #{self.class}"
    end

    def add_link(_link)
      raise UnsupportedOperationError, "Operation #{__method__} not supported on #{self.class}"
    end

    def add_control(_control)
      raise UnsupportedOperationError, "Operation #{__method__} not supported on #{self.class}"
    end

    def add_subresource(_subresource)
      raise UnsupportedOperationError, "Operation #{__method__} not supported on #{self.class}"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
yaks-0.7.6 lib/yaks/null_resource.rb
yaks-0.7.5 lib/yaks/null_resource.rb
yaks-0.7.4 lib/yaks/null_resource.rb
yaks-0.7.3 lib/yaks/null_resource.rb
yaks-0.7.2 lib/yaks/null_resource.rb
yaks-0.7.1 lib/yaks/null_resource.rb
yaks-0.7.0 lib/yaks/null_resource.rb