class VagrantCloud::Organization
Attributes
Public Class Methods
Source
# 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
Calls superclass method
VagrantCloud::Data::Mutable::new
Public Instance Methods
Source
# 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
Add a new box to the organization
@param [String] name Name of the box @return [Box]
Source
# 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
Check if this instance is dirty
@param [Boolean] deep Check nested instances @return [Boolean] instance is dirty
Calls superclass method
VagrantCloud::Data::Mutable#dirty?
Source
# File lib/vagrant_cloud/organization.rb, line 57 def save boxes.map(&:save) self end
Save the organization
@return [self] @note This only saves boxes within organization