Class: Weatherzone::Resource

Inherits:
Object
  • Object
show all
Includes:
SAXMachine
Defined in:
lib/weatherzone/resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.has_attribute(attr_name, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/weatherzone/resource.rb', line 23

def self.has_attribute(attr_name, options={})
  element_name = options[:on_elements] || self.top_level_element
  if element_name.is_a? Array
    element_name.each do |e|
      element e, :value => attr_name, :as => "#{e}_#{attr_name}"
    end
  else
    method_name = (element_name == self.top_level_element) ? "#{attr_name}" : "#{element_name}_#{attr_name}"
    element element_name, :value => attr_name, :as => method_name
  end
end

.has_elements(*elements) ⇒ Object



17
18
19
20
21
# File 'lib/weatherzone/resource.rb', line 17

def self.has_elements(*elements)
  elements.each do |e|
    element e
  end
end

.inherited(klass) ⇒ Object



11
12
13
14
15
# File 'lib/weatherzone/resource.rb', line 11

def self.inherited(klass)
  klass.class_eval do
    self.top_level_element ||= self.name.downcase
  end
end

Instance Method Details

#settingsObject



35
36
37
# File 'lib/weatherzone/resource.rb', line 35

def settings
  Weatherzone::Settings.instance
end