Module: Speculation::NamespacedSymbols
- Included in:
- Speculation, Test
- Defined in:
- lib/speculation/namespaced_symbols.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#ns(name_or_namespace, name = nil) ⇒ Symbol
Concatenation of ‘namespace` and `name`.
Class Method Details
.namespace(sym) ⇒ Object
32 33 34 35 |
# File 'lib/speculation/namespaced_symbols.rb', line 32 def self.namespace(sym) parts = sym.to_s.split("/") parts.first if parts.count == 2 end |
.namespaced_name(sym) ⇒ Object
28 29 30 |
# File 'lib/speculation/namespaced_symbols.rb', line 28 def self.namespaced_name(sym) sym.to_s.split("/").last end |
.symbol(ns, name) ⇒ Object
22 23 24 25 26 |
# File 'lib/speculation/namespaced_symbols.rb', line 22 def self.symbol(ns, name) ns = ns.name if ns.is_a?(Module) :"#{ns}/#{name}" end |
Instance Method Details
#ns(name_or_namespace, name = nil) ⇒ Symbol
Returns concatenation of ‘namespace` and `name`.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/speculation/namespaced_symbols.rb', line 11 def ns(name_or_namespace, name = nil) if name namespace = name_or_namespace else name = name_or_namespace namespace = is_a?(Module) ? self : self.class end NamespacedSymbols.symbol(namespace, name) end |