Class: ActiveSP::Field

Inherits:
Base
  • Object
show all
Extended by:
Caching
Includes:
InSite, Util
Defined in:
lib/activesp/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attribute, #attribute_type, #attribute_types, #attributes, #has_attribute?, #has_writable_attribute?, #method_missing, #reload, #set_attribute

Constructor Details

#initialize(scope, id, name, type, parent, attributes_before_type_cast) ⇒ Field

There is no call to get to the field info directly, so these should always be accessed through the site or list they belong to. Hence, we do not use caching here as it is useless.



47
48
49
50
# File 'lib/activesp/field.rb', line 47

def initialize(scope, id, name, type, parent, attributes_before_type_cast)
  @scope, @ID, @Name, @internal_type, @parent, @attributes_before_type_cast = scope, id, name, type, parent, attributes_before_type_cast
  @site = Site === @scope ? @scope : @scope.site
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveSP::Base

Instance Attribute Details

#IDObject (readonly)



35
36
37
# File 'lib/activesp/field.rb', line 35

def ID
  @ID
end

#internal_typeObject (readonly)



35
36
37
# File 'lib/activesp/field.rb', line 35

def internal_type
  @internal_type
end

#NameObject (readonly)



35
36
37
# File 'lib/activesp/field.rb', line 35

def Name
  @Name
end

#parentField (readonly)

Returns the parent field. This is the field defined on the containing site in case the field has a list as scope

Returns:



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

def parent
  @parent
end

#scopeSite, List (readonly)

Returns the scope of the field. This can be a site or a list

Returns:



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

def scope
  @scope
end

Instance Method Details

#keyString

See Base#key

Returns:

  • (String)


54
55
56
# File 'lib/activesp/field.rb', line 54

def key
  encode_key("A", [@scope.key, @ID])
end

#ListObject



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

def List
  list_for_lookup
end

#MultObject



69
70
71
# File 'lib/activesp/field.rb', line 69

def Mult
  !!attributes["Mult"]
end

#ReadOnlyObject



74
75
76
# File 'lib/activesp/field.rb', line 74

def ReadOnly
  !!attributes["ReadOnly"]
end

#savevoid

This method returns an undefined value.

See Base#save



80
81
82
# File 'lib/activesp/field.rb', line 80

def save
  p untype_cast_attributes(@site, nil, internal_attribute_types, changed_attributes)
end

#to_sObject Also known as: inspect



85
86
87
# File 'lib/activesp/field.rb', line 85

def to_s
  "#<ActiveSP::Field name=#{self.Name}>"
end

#TypeObject



64
65
66
# File 'lib/activesp/field.rb', line 64

def Type
  translate_internal_type(self)
end