Class: Idcf::Dns::Resources::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/idcf/dns/resources/base.rb

Overview

Base resource class

Direct Known Subclasses

Record, Zone

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, attributes = {}) ⇒ Base

Constructor

Parameters:

  • client (Client)

    client object

  • attributes (Hash) (defaults to: {})

    attributes for resource



39
40
41
42
# File 'lib/idcf/dns/resources/base.rb', line 39

def initialize(client, attributes = {})
  @client = client
  self.attributes = attributes
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/idcf/dns/resources/base.rb', line 8

def client
  @client
end

Class Method Details

.class_nameObject



17
18
19
# File 'lib/idcf/dns/resources/base.rb', line 17

def class_name
  to_s.gsub(/^#<Class|>$/, "").split(/::/).last
end

.generate_readersObject



22
23
24
25
26
27
# File 'lib/idcf/dns/resources/base.rb', line 22

def generate_readers
  validator_class.valid_attributes.each do |name, properties|
    next if properties[:reader] == false
    attr_reader name
  end
end

.inherited(subclass) ⇒ Object



12
13
14
# File 'lib/idcf/dns/resources/base.rb', line 12

def inherited(subclass)
  subclass.send(:generate_readers)
end

.validator_classObject



30
31
32
# File 'lib/idcf/dns/resources/base.rb', line 30

def validator_class
  "Idcf::Dns::Validators::#{class_name}".constantize
end

Instance Method Details

#inspectObject

Inspect this class



45
46
47
# File 'lib/idcf/dns/resources/base.rb', line 45

def inspect
  "#<#{self.class}:0x%014x @name=#{name} @uuid=#{uuid}>" % [object_id]
end