Module: Fog::Attributes::ClassMethods

Included in:
Collection, Model
Defined in:
lib/fog/core/attributes.rb

Instance Method Summary collapse

Instance Method Details

#_load(marshalled) ⇒ Object



5
6
7
# File 'lib/fog/core/attributes.rb', line 5

def _load(marshalled)
  new(Marshal.load(marshalled))
end

#aliasesObject



9
10
11
# File 'lib/fog/core/attributes.rb', line 9

def aliases
  @aliases ||= {}
end

#attribute(name, options = {}) ⇒ Object



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

def attribute(name, options = {})
  type = options.fetch(:type, 'default').to_s.capitalize
  default = options.fetch(:default, false)
  Fog::Attributes::const_get(type).new(self, name, options).create
  attributes << name
  default_values[name] = default if default
  Array(options[:aliases]).each do |new_alias|
    aliases[new_alias] = name
  end
end

#attributesObject



13
14
15
# File 'lib/fog/core/attributes.rb', line 13

def attributes
  @attributes ||= []
end

#default_valuesObject



17
18
19
# File 'lib/fog/core/attributes.rb', line 17

def default_values
  @default_values ||= {}
end

#identity(name, options = {}) ⇒ Object



32
33
34
35
# File 'lib/fog/core/attributes.rb', line 32

def identity(name, options = {})
  @identity = name
  self.attribute(name, options)
end

#ignore_attributes(*args) ⇒ Object



37
38
39
# File 'lib/fog/core/attributes.rb', line 37

def ignore_attributes(*args)
  @ignored_attributes = args.collect {|attr| attr.to_s }
end

#ignored_attributesObject



41
42
43
# File 'lib/fog/core/attributes.rb', line 41

def ignored_attributes
  @ignored_attributes ||= []
end