Class: Docks::Containers::Symbol
- Inherits:
-
Base
- Object
- Base
- Docks::Containers::Symbol
show all
- Defined in:
- lib/docks/containers/symbol_container.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#==, #[], #[]=, #delete, #fetch, #method_missing, #respond_to?, #summarized?, #tags, #to_h, #update
Constructor Details
#initialize(symbol_hash = {}) ⇒ Symbol
Returns a new instance of Symbol.
15
16
17
18
19
20
|
# File 'lib/docks/containers/symbol_container.rb', line 15
def initialize(symbol_hash = {})
super
self[:symbol_type] = self.class.type
@properties = []
@methods = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Docks::Containers::Base
Instance Attribute Details
#belongs_to ⇒ Object
Returns the value of attribute belongs_to.
6
7
8
|
# File 'lib/docks/containers/symbol_container.rb', line 6
def belongs_to
@belongs_to
end
|
#methods ⇒ Object
Returns the value of attribute methods.
6
7
8
|
# File 'lib/docks/containers/symbol_container.rb', line 6
def methods
@methods
end
|
#properties ⇒ Object
Returns the value of attribute properties.
6
7
8
|
# File 'lib/docks/containers/symbol_container.rb', line 6
def properties
@properties
end
|
Class Method Details
.from_symbol(symbol) ⇒ Object
10
11
12
13
|
# File 'lib/docks/containers/symbol_container.rb', line 10
def self.from_symbol(symbol)
return if self == symbol.class
new(symbol.to_h)
end
|
.type ⇒ Object
8
|
# File 'lib/docks/containers/symbol_container.rb', line 8
def self.type; "symbol" end
|
Instance Method Details
#add_member(symbol) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/docks/containers/symbol_container.rb', line 33
def add_member(symbol)
symbol.for = fetch(:name)
symbol.belongs_to = self
symbol.static = true
if symbol.kind_of?(Variable)
symbol.property = true
@properties << symbol
else
symbol.method = true
@methods << symbol
end
end
|
#add_members(*symbols) ⇒ Object
47
48
49
|
# File 'lib/docks/containers/symbol_container.rb', line 47
def add_members(*symbols)
symbols.each { |symbol| add_member(symbol) }
end
|
#find(descriptor) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/docks/containers/symbol_container.rb', line 51
def find(descriptor)
descriptor = Descriptor.new(descriptor)
return self if matches_exactly?(descriptor)
members.find { |member| member.find(descriptor) } || false
end
|
#has_members? ⇒ Boolean
31
|
# File 'lib/docks/containers/symbol_container.rb', line 31
def has_members?; !members.empty? end
|
#member? ⇒ Boolean
25
26
27
|
# File 'lib/docks/containers/symbol_container.rb', line 25
def member?
self[:property] == true || self[:method] == true
end
|
#members ⇒ Object
29
|
# File 'lib/docks/containers/symbol_container.rb', line 29
def members; @methods + @properties end
|
#private? ⇒ Boolean
22
|
# File 'lib/docks/containers/symbol_container.rb', line 22
def private?; fetch(:access, nil) == Docks::Types::Access::PRIVATE end
|
#public? ⇒ Boolean
23
|
# File 'lib/docks/containers/symbol_container.rb', line 23
def public?; !private? end
|
#summary ⇒ Object
69
70
71
72
73
74
|
# File 'lib/docks/containers/symbol_container.rb', line 69
def summary
summary = super
summary.properties = @properties.map(&:summary)
summary.methods = @methods.map(&:summary)
summary
end
|
#symbol_id ⇒ Object
58
59
60
|
# File 'lib/docks/containers/symbol_container.rb', line 58
def symbol_id
"#{fetch(:symbol_type)}-#{fetch(:name)}"
end
|
#to_descriptor ⇒ Object
62
63
64
65
66
67
|
# File 'lib/docks/containers/symbol_container.rb', line 62
def to_descriptor
descriptor = ""
descriptor << "#{belongs_to.name}::" unless belongs_to.nil?
descriptor << fetch(:name)
descriptor
end
|