Class: Sharepoint::ObjectProperties

Inherits:
Object
  • Object
show all
Defined in:
lib/sharepoint-properties.rb

Direct Known Subclasses

Object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, data) ⇒ ObjectProperties

Returns a new instance of ObjectProperties


7
8
9
10
11
12
13
14
15
# File 'lib/sharepoint-properties.rb', line 7

def initialize site, data
  @site                      = site
  @data                      = data
  @updated_data              = Hash.new
  @properties                = Hash.new
  @properties_names          = Array.new
  @properties_original_names = Array.new
  initialize_properties
end

Instance Attribute Details

#dataObject

Returns the value of attribute data


5
6
7
# File 'lib/sharepoint-properties.rb', line 5

def data
  @data
end

#siteObject

Returns the value of attribute site


5
6
7
# File 'lib/sharepoint-properties.rb', line 5

def site
  @site
end

#updated_dataObject

Returns the value of attribute updated_data


5
6
7
# File 'lib/sharepoint-properties.rb', line 5

def updated_data
  @updated_data
end

Instance Method Details

#add_properties(properties) ⇒ Object


36
37
38
39
40
# File 'lib/sharepoint-properties.rb', line 36

def add_properties properties
  properties.each do |property|
    add_property property
  end
end

#add_property(property, value = nil) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sharepoint-properties.rb', line 17

def add_property property, value = nil
  editable                = is_property_editable? property
  property                = property.to_s
  @data[property]         = nil   if @data[property].nil?
  @data[property]         = value unless value.nil?
  @updated_data[property] = value if (@initialize_properties == false) and (editable == true)
  unless @properties_original_names.include? property
    @properties_names          << property.underscore.to_sym
    @properties_original_names << property
    define_singleton_method property.underscore do
      get_property property
    end
    define_singleton_method property.underscore + '=' do |new_value|
      @data[property]         = new_value
      @updated_data[property] = new_value
    end if editable == true
  end
end

#available_propertiesObject


42
43
44
# File 'lib/sharepoint-properties.rb', line 42

def available_properties
  @properties_names
end