Class: NodeEntityAbstract
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- NodeEntityAbstract
show all
- Extended by:
- Forwardable
- Defined in:
- app/models/node_entity_abstract.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of NodeEntityAbstract.
26
27
28
29
|
# File 'app/models/node_entity_abstract.rb', line 26
def initialize(attrs=nil)
super(nil)
self.attributes = attrs
end
|
Class Method Details
._find ⇒ Object
12
|
# File 'app/models/node_entity_abstract.rb', line 12
alias :_find :find
|
.find(*args) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/models/node_entity_abstract.rb', line 13
def find(*args)
nodes = Node.send("find_#{table_name}",*args)
case nodes
when Node
return nodes.entity
when Array
return nodes.collect{|n| n.entity}
else
return nodes
end
end
|
Instance Method Details
#attributes=(attrs = nil) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/models/node_entity_abstract.rb', line 31
def attributes=(attrs=nil)
attrs_node = Hash.new
attrs_org = attrs
if attrs
attrs = attrs.dup
Node.column_names.each{|cname|
if ( v=(attrs.delete(cname)||attrs.delete(cname.to_sym)) )
attrs_node[cname] = v
end
}
end
super(attrs)
if n = node
n.attributes= attrs_node
else
n = Node.new(attrs_node)
end
n.node_type = Node.const_get(self.class.table_name.singularize.upcase)
self.node = n
n.entity = self
return attrs_org
end
|
#node ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/models/node_entity_abstract.rb', line 54
def node
return @node if @node
if node_id
@node = Node.find(node_id, :user => :all)
return @node
end
return nil
end
|