class VagrantCloud::Organization
Attributes
account[R]
Public Class Methods
new(account:, **opts)
click to toggle source
Calls superclass method
VagrantCloud::Data::Mutable::new
# File lib/vagrant_cloud/organization.rb, line 10 def initialize(account:, **opts) @account = account opts[:boxes] ||= [] super(**opts) bxs = boxes.map do |b| if !b.is_a?(Box) b = Box.load(organization: self, **b) end b end clean(data: {boxes: bxs}) end
Public Instance Methods
add_box(name)
click to toggle source
Add a new box to the organization
@param [String] name Name of the box @return [Box]
# File lib/vagrant_cloud/organization.rb, line 27 def add_box(name) if boxes.any? { |b| b.name == name } raise Error::BoxError::BoxExistsError, "Box with name #{name} already exists" end b = Box.new(organization: self, name: name) clean(data: {boxes: boxes + [b]}) b end
dirty?(key=nil, deep: false)
click to toggle source
Check if this instance is dirty
@param [Boolean] deep Check nested instances @return [Boolean] instance is dirty
Calls superclass method
VagrantCloud::Data::Mutable#dirty?
# File lib/vagrant_cloud/organization.rb, line 41 def dirty?(key=nil, deep: false) if key super(key) else d = super() if deep && !d d = boxes.any? { |b| b.dirty?(deep: true) } end d end end
save()
click to toggle source
Save the organization
@return [self] @note This only saves boxes within organization
# File lib/vagrant_cloud/organization.rb, line 57 def save boxes.map(&:save) self end