Class/Module Index [+]

Quicksearch

Fog::Attributes::ClassMethods

Public Instance Methods

_load(marshalled) click to toggle source
# File lib/fog/core/attributes.rb, line 5
def _load(marshalled)
  new(Marshal.load(marshalled))
end
aliases() click to toggle source
# File lib/fog/core/attributes.rb, line 9
def aliases
  @aliases ||= {}
end
attribute(name, options = {}) click to toggle source
# File lib/fog/core/attributes.rb, line 17
def attribute(name, options = {})
  class_eval           def #{name}            attributes[:#{name}]          end, __FILE__, __LINE__
  case options[:type]
  when :boolean
    class_eval             def #{name}=(new_#{name})              attributes[:#{name}] = case new_#{name}              when true,'true'                true              when false,'false'                false              end            end, __FILE__, __LINE__
  when :float
    class_eval             def #{name}=(new_#{name})              attributes[:#{name}] = new_#{name}.to_f            end, __FILE__, __LINE__
  when :integer
    class_eval             def #{name}=(new_#{name})              attributes[:#{name}] = new_#{name}.to_i            end, __FILE__, __LINE__
  when :string
    class_eval             def #{name}=(new_#{name})              attributes[:#{name}] = new_#{name}.to_s            end, __FILE__, __LINE__
  when :time
    class_eval             def #{name}=(new_#{name})              attributes[:#{name}] = if new_#{name}.nil? || new_#{name} == "" || new_#{name}.is_a?(Time)                new_#{name}              else                Time.parse(new_#{name})              end            end, __FILE__, __LINE__
  when :array
    class_eval           def #{name}=(new_#{name})            attributes[:#{name}] = [*new_#{name}]          end, __FILE__, __LINE__
  else
    if squash = options[:squash]
      class_eval               def #{name}=(new_data)                if new_data.is_a?(Hash)                  if new_data.has_key?(:'#{squash}')                    attributes[:#{name}] = new_data[:'#{squash}']                  elsif new_data.has_key?("#{squash}")                    attributes[:#{name}] = new_data["#{squash}"]                  else                    attributes[:#{name}] = [ new_data ]                  end                else                  attributes[:#{name}] = new_data                end              end, __FILE__, __LINE__
    else
      class_eval               def #{name}=(new_#{name})                attributes[:#{name}] = new_#{name}              end, __FILE__, __LINE__
    end
  end
  @attributes ||= []
  @attributes |= [name]
  for new_alias in [*options[:aliases]]
    aliases[new_alias] = name
  end
end
attributes() click to toggle source
# File lib/fog/core/attributes.rb, line 13
def attributes
  @attributes ||= []
end
identity(name, options = {}) click to toggle source
# File lib/fog/core/attributes.rb, line 101
def identity(name, options = {})
  @identity = name
  self.attribute(name, options)
end
ignore_attributes(*args) click to toggle source
# File lib/fog/core/attributes.rb, line 106
def ignore_attributes(*args)
  @ignored_attributes = args.collect {|attr| attr.to_s }
end
ignored_attributes() click to toggle source
# File lib/fog/core/attributes.rb, line 110
def ignored_attributes
  @ignored_attributes ||= []
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.