Class: Zobi::Discover
- Inherits:
-
Struct
- Object
- Struct
- Zobi::Discover
- Defined in:
- lib/zobi/discover.rb
Constant Summary collapse
- CONFIG =
{ decorated: { suffix: 'Decorator', resource: 'ResourceDecorator', collection: 'CollectionDecorator' } }.freeze
Instance Attribute Summary collapse
-
#behavior ⇒ Object
Returns the value of attribute behavior.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#behavior ⇒ Object
Returns the value of attribute behavior
4 5 6 |
# File 'lib/zobi/discover.rb', line 4 def behavior @behavior end |
#klass ⇒ Object
Returns the value of attribute klass
4 5 6 |
# File 'lib/zobi/discover.rb', line 4 def klass @klass end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/zobi/discover.rb', line 4 def type @type end |
Class Method Details
.classes_for_namespaces(namespaces, base_name) ⇒ Object
63 64 65 66 67 |
# File 'lib/zobi/discover.rb', line 63 def classes_for_namespaces namespaces, base_name namespaces.map{|ns| "#{ns == '::' ? ns : "#{ns}::"}#{base_name}" } end |
Instance Method Details
#resolve ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/zobi/discover.rb', line 13 def resolve discovery.each do |klass| begin return klass.constantize rescue NameError next end end "Zobi::#{fallback}".constantize end |