Class: Upcheck::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/upcheck/resource.rb

Direct Known Subclasses

Component, Incident, Incident::Update

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Resource

Returns a new instance of Resource.



15
16
17
# File 'lib/upcheck/resource.rb', line 15

def initialize(attributes)
  @attributes = attributes || {}
end

Class Method Details

.attribute(*names) ⇒ Object



5
6
7
8
9
# File 'lib/upcheck/resource.rb', line 5

def self.attribute(*names)
  names.each do |name|
    define_method(name) { @attributes[name.to_s] }
  end
end

.build_all(payloads) ⇒ Object



11
12
13
# File 'lib/upcheck/resource.rb', line 11

def self.build_all(payloads)
  Array(payloads).map { |payload| new(payload) }
end