Class: ActiveSP::GhostField

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/activesp/ghost_field.rb

Overview

This class represents the field definitions for objects in SharePoint for which the fields cannot be changed and are thus not represented by an object in SharePoint. These include fields of sites, lists, users, grouos, roles, content types and fields. The interface of this class is not as complete as the interface if a Field, mainly because it does not make much sense to do so

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, mult, read_only, display_name = name) ⇒ GhostField

Returns a new instance of GhostField.



41
42
43
# File 'lib/activesp/ghost_field.rb', line 41

def initialize(name, type, mult, read_only, display_name = name)
  @Name, @DisplayName, @internal_type, @Mult, @ReadOnly = name, display_name, type, mult, read_only
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &b) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/activesp/ghost_field.rb', line 71

def method_missing(m, *a, &b)
  ms = m.to_s
  if a.length == 0 && has_attribute?(ms)
    attribute(ms)
  else
    super
  end
end

Instance Attribute Details

#DisplayNameObject (readonly)



38
39
40
# File 'lib/activesp/ghost_field.rb', line 38

def DisplayName
  @DisplayName
end

#internal_typeObject (readonly)



38
39
40
# File 'lib/activesp/ghost_field.rb', line 38

def internal_type
  @internal_type
end

#MultObject (readonly)



38
39
40
# File 'lib/activesp/ghost_field.rb', line 38

def Mult
  @Mult
end

#NameObject (readonly)



38
39
40
# File 'lib/activesp/ghost_field.rb', line 38

def Name
  @Name
end

#ReadOnlyObject (readonly)



38
39
40
# File 'lib/activesp/ghost_field.rb', line 38

def ReadOnly
  @ReadOnly
end

#RequiredObject (readonly)



38
39
40
# File 'lib/activesp/ghost_field.rb', line 38

def Required
  @Required
end

Instance Method Details

#attribute(name) ⇒ Integer, ...

Returns the value of the attribute of the given name, or nil if this object does not have an attribute by the given name

Parameters:

  • name (String)

    The name of the attribute

Returns:

  • (Integer, Float, String, Time, Boolean, Base)


59
60
61
# File 'lib/activesp/ghost_field.rb', line 59

def attribute(name)
  current_attributes[name]
end

#attributesHash{String => Integer, Float, String, Time, Boolean, Base}

Returns the attributes of this object as a Hash

Returns:

  • (Hash{String => Integer, Float, String, Time, Boolean, Base})


52
53
54
# File 'lib/activesp/ghost_field.rb', line 52

def attributes
  original_attributes.dup
end

#has_attribute?(name) ⇒ Boolean

Returns whether or not this object has an attribute with the given name

Parameters:

  • name (String)

    The name of the attribute

Returns:

  • (Boolean)


66
67
68
# File 'lib/activesp/ghost_field.rb', line 66

def has_attribute?(name)
  current_attributes.has_key?(name)
end

#TypeObject



46
47
48
# File 'lib/activesp/ghost_field.rb', line 46

def Type
  translate_internal_type(self)
end