Class: ActiveZone::Provider::Zone Abstract

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Callbacks
Includes:
ActiveModel::AttributeAssignment, ActiveModel::Attributes, ActiveModel::Conversion, ActiveModel::Dirty, ActiveModel::Model, ActiveModel::Serialization, ActiveModel::Validations, Zone::Builtins
Defined in:
lib/active_zone/provider/zone.rb

Overview

This class is abstract.

Subclass and override to create a functional Zone model

An Active Model class representing a DNS Zone at a provider.

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Zone::Builtins::Persistence

#destroy, #destroy!, #save, #save!, #update, #update!

Constructor Details

#initialize(provider = ActiveZone.provider, **attributes) ⇒ Zone

Returns a new instance of Zone.

Parameters:

  • provider (ActiveZone::Provider) (defaults to: ActiveZone.provider)

    Provider to store the zone with

  • attributes (Hash)

    Attributes for the zone

Options Hash (**attributes):

  • :resources (Array)

    Array of resources mappable to Resource

  • :name (String)

    Name of the zone

  • :persisted (TrueClass, FalseClass)

    Whether the zone is persisted at the provider



27
28
29
30
31
32
# File 'lib/active_zone/provider/zone.rb', line 27

def initialize(provider = ActiveZone.provider, **attributes)
  @provider = provider
  (attributes[:resources] = attributes[:resources].map { |el| ActiveZone::Resource.new(**el) }) if attributes[:resources]
  super(attributes)
  clear_changes_information
end

Instance Attribute Details

#persistedTrueClass, FalseClass (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether the current zone is persisted with a provider

Returns:

  • (TrueClass)

    if true

  • (FalseClass)

    if false



20
21
22
# File 'lib/active_zone/provider/zone.rb', line 20

def persisted
  @persisted
end

#providerActiveZone::Provider (readonly)

Provider the zone will be stored at



51
52
53
# File 'lib/active_zone/provider/zone.rb', line 51

def provider
  @provider
end

Class Method Details

.method_missing(method_name) ⇒ Object

Delegate missing class methods to all



35
36
37
# File 'lib/active_zone/provider/zone.rb', line 35

def self.method_missing(method_name, *, &)
  all.send(method_name, *, &)
end

.respond_to_missing?(method_name, include_private = false) ⇒ TrueClass, FalseClass

Delegate missing class methods to all

Returns:

  • (TrueClass)

    if true

  • (FalseClass)

    if false



41
42
43
# File 'lib/active_zone/provider/zone.rb', line 41

def self.respond_to_missing?(method_name, include_private = false)
  all.respond_to?(method_name, include_private)
end

Instance Method Details

#delete!TrueClass, FalseClass

This method is abstract.

Override in subclass with how to delete a Zone at your provider.

Underlying method to delete the current zone

Returns:

  • (TrueClass)

    if true

  • (FalseClass)

    if false

Raises:

  • (NotImplementedError)


66
67
68
# File 'lib/active_zone/provider/zone.rb', line 66

def delete!
  raise NotImplementedError
end

#persist!(**options, &block) ⇒ TrueClass, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.

Override in subclass with how to persist a Zone at your provider

Underlying method to save the current zone

Returns:

  • (TrueClass)

    if true

  • (FalseClass)

    if false

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/active_zone/provider/zone.rb', line 59

def persist!(**options, &block)
  raise NotImplementedError
end

#persisted?TrueClass, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether the current zone is persisted with a provider

Returns:

  • (TrueClass)

    if true

  • (FalseClass)

    if false

See Also:



72
73
74
# File 'lib/active_zone/provider/zone.rb', line 72

def persisted?
  persisted
end