Class: AD::Framework::StructuralClass

Inherits:
Object
  • Object
show all
Includes:
Patterns::Callbacks, Patterns::HasSchema, Patterns::Persistence, Patterns::Searchable, Patterns::Validations
Defined in:
lib/ad-framework/structural_class.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Patterns::Validations

included

Methods included from Patterns::Callbacks

included

Methods included from Patterns::Searchable

included

Methods included from Patterns::Persistence

included

Methods included from Patterns::HasSchema

included

Constructor Details

#initialize(attributes = {}) ⇒ StructuralClass

Returns a new instance of StructuralClass.



20
21
22
23
24
25
26
27
28
29
# File 'lib/ad-framework/structural_class.rb', line 20

def initialize(attributes = {})
  self.meta_class = class << self; self; end

  self.fields = AD::Framework::Fields.new(attributes.delete(:fields) || {})
  if (treebase = (attributes.delete(:treebase) || attributes.delete("treebase")))
    self.treebase = treebase
  end

  self.attributes = attributes
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



18
19
20
# File 'lib/ad-framework/structural_class.rb', line 18

def fields
  @fields
end

#meta_classObject

Returns the value of attribute meta_class.



18
19
20
# File 'lib/ad-framework/structural_class.rb', line 18

def meta_class
  @meta_class
end

Class Method Details

.connectionObject



52
53
54
# File 'lib/ad-framework/structural_class.rb', line 52

def connection
  AD::Framework.connection
end

Instance Method Details

#connectionObject



38
39
40
# File 'lib/ad-framework/structural_class.rb', line 38

def connection
  self.class.connection
end

#inspectObject



42
43
44
45
46
47
48
# File 'lib/ad-framework/structural_class.rb', line 42

def inspect
  (attr_display = self.attributes.collect do |(name, value)|
    "#{name}: #{value.inspect}"
  end)
  attr_display << "treebase: #{self.treebase.inspect}"
  [ "#<#{self.class} ", attr_display.sort.join(", "), ">" ].join
end

#treebaseObject



31
32
33
# File 'lib/ad-framework/structural_class.rb', line 31

def treebase
  self.schema.treebase
end

#treebase=(new_value) ⇒ Object



34
35
36
# File 'lib/ad-framework/structural_class.rb', line 34

def treebase=(new_value)
  self.schema.treebase = new_value
end