Class: Occi::Core::AttributeProperty

Inherits:
Object
  • Object
show all
Includes:
Helpers::Inspect
Defined in:
lib/occi/core/attribute_property.rb

Direct Known Subclasses

Attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Inspect

#inspect

Constructor Details

#initialize(properties = {}) ⇒ AttributeProperty

Returns a new instance of AttributeProperty

Parameters:

  • properties (Hash) (defaults to: {})
  • default (Hash)

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/occi/core/attribute_property.rb', line 11

def initialize(properties={})
  case properties
    when Occi::Core::AttributeProperty
      self._default = properties._default
      self._type = properties._type
      self._required = properties._required
      self._mutable = properties._mutable
      self._pattern = properties._pattern
    else
      self._default = properties[:default]
      self._type = properties[:type] ||= 'string'
      self._required = properties[:required] ||= false
      self._mutable = properties[:mutable] ||= false
      self._pattern = properties[:pattern] ||= '.*'
  end
end

Instance Attribute Details

#_defaultObject

Returns the value of attribute _default


7
8
9
# File 'lib/occi/core/attribute_property.rb', line 7

def _default
  @_default
end

#_descriptionObject

Returns the value of attribute _description


7
8
9
# File 'lib/occi/core/attribute_property.rb', line 7

def _description
  @_description
end

#_mutableObject

Returns the value of attribute _mutable


7
8
9
# File 'lib/occi/core/attribute_property.rb', line 7

def _mutable
  @_mutable
end

#_patternObject

Returns the value of attribute _pattern


7
8
9
# File 'lib/occi/core/attribute_property.rb', line 7

def _pattern
  @_pattern
end

#_requiredObject

Returns the value of attribute _required


7
8
9
# File 'lib/occi/core/attribute_property.rb', line 7

def _required
  @_required
end

#_typeObject

Returns the value of attribute _type


7
8
9
# File 'lib/occi/core/attribute_property.rb', line 7

def _type
  @_type
end

Instance Method Details

#as_json(options = {}) ⇒ Object


36
37
38
39
40
41
42
43
44
45
# File 'lib/occi/core/attribute_property.rb', line 36

def as_json(options={})
  hash = Hashie::Mash.new
  hash.type = self._type if self._type
  hash.required = self._required if self._required
  hash.mutable = self._mutable if self._mutable
  hash.default = self._default if self._default
  hash.description = self._description if self._description
  hash.pattern = self._pattern if self._pattern
  hash
end

#mutable?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/occi/core/attribute_property.rb', line 32

def mutable?
  self._mutable
end

#required?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/occi/core/attribute_property.rb', line 28

def required?
  self._required
end