Class: Yaks::NullResource

Inherits:
Resource show all
Defined in:
lib/yaks/null_resource.rb

Instance Method Summary collapse

Methods inherited from Resource

#[], #add_rel, #find_form, #members, #self_link, #with_collection

Methods included from Util::Deprecated

#deprecated_alias

Constructor Details

#initialize(opts = {}) ⇒ NullResource

Returns a new instance of NullResource.



6
7
8
9
10
11
# File 'lib/yaks/null_resource.rb', line 6

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

Instance Method Details

#add_form(_form) ⇒ Object



42
43
44
# File 'lib/yaks/null_resource.rb', line 42

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


38
39
40
# File 'lib/yaks/null_resource.rb', line 38

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

#add_subresource(_subresource) ⇒ Object



46
47
48
# File 'lib/yaks/null_resource.rb', line 46

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

#collection?Boolean

rubocop:disable Style/TrivialAccessors

Returns:

  • (Boolean)


17
18
19
# File 'lib/yaks/null_resource.rb', line 17

def collection? # rubocop:disable Style/TrivialAccessors
  @collection
end

#eachObject



13
14
15
# File 'lib/yaks/null_resource.rb', line 13

def each
  to_enum
end

#mapObject



29
30
31
32
# File 'lib/yaks/null_resource.rb', line 29

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

#merge_attributes(_new_attrs) ⇒ Object



34
35
36
# File 'lib/yaks/null_resource.rb', line 34

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

#null_resource?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/yaks/null_resource.rb', line 21

def null_resource?
  true
end

#seqObject



25
26
27
# File 'lib/yaks/null_resource.rb', line 25

def seq
  []
end