class Rancher::Collection
A Collection
of Resources
Public Class Methods
new(data)
click to toggle source
Calls superclass method
# File lib/rancher/collection.rb, line 7 def initialize(data) @data = data[:data] if data.key?(:data) super(data) end
Public Instance Methods
create(attrs)
click to toggle source
# File lib/rancher/collection.rb, line 12 def create(attrs) attrs = attrs.meta if attrs.is_a?(Rancher::Resource) Rancher.post get_link('self'), attrs end
each() { |d| ... }
click to toggle source
# File lib/rancher/collection.rb, line 25 def each return @data.enum_for(:each) unless block_given? @data.each { |d| yield d } end
remove!(id_or_obj)
click to toggle source
# File lib/rancher/collection.rb, line 18 def remove!(id_or_obj) id = id_or_obj.get_id if id_or_obj.is_a?(Rancher::Resource) link = get_link('self') + "/#{id}" Rancher.delete link end
Private Instance Methods
schema_field(name)
click to toggle source
# File lib/rancher/collection.rb, line 33 def schema_field(name) type_name = get_type type = Rancher.types[type_name.to_sym] type.collection_field(name) if type type end