Module: Sfn::Resource::Attributes::ClassMethods

Defined in:
lib/satisfaction/resource/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attribute(name, options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/satisfaction/resource/attributes.rb', line 20

def attribute(name, options)
  options.reverse_merge!(:type => 'nil')
  raise "Name can't be empty" if name.blank?
  
  class_eval "    def \#{name}\n      self.load unless self.loaded?\n      @\#{name} ||= decode_raw_attribute(@attributes['\#{name}'], \#{options[:type]}) if @attributes\n    end\n  EOS\nend\n"

#attributes(*names) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/satisfaction/resource/attributes.rb', line 12

def attributes(*names)
  options = names.extract_options!
  
  names.each do |name|
    attribute name, options unless name.blank?
  end
end