Module: DocWrapper::Base

Defined in:
lib/doc_wrapper/base.rb

Class Method Summary collapse

Class Method Details

.infer_doc_origem(src, opts) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/doc_wrapper/base.rb', line 29

def self.infer_doc_origem src, opts
  origem = opts[:origin] || opts[:origem] || opts[:owner] || opts[:doc]
  unless origem
    if src.is_a? Hash
      origem = src[:origin] || src[:origem] || src[:owner] || src[:doc]
    else
      origem = src
    end
  end
  origem = origem.to_s.underscore.strip.gsub(/-/, "_")
  origem
end

.klass_name(origem, opts = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/doc_wrapper/base.rb', line 18

def self.klass_name origem, opts={}
  modulle = "#{opts[:module].to_s.underscore}::" if opts[:module]
  prefix = "#{opts[:prefix]}_" if opts[:prefix]
  sufix = "_#{opts[:sufix]}" if opts[:sufix]

  prefix = "DocBy" unless prefix
  modulle = "DocWrapper::" unless modulle
  
  "#{modulle}#{prefix.camelize}#{origem.camelize}#{sufix}".camelize
end

.to_target_doc(src, opts = {}) ⇒ Object



4
5
6
7
# File 'lib/doc_wrapper/base.rb', line 4

def self.to_target_doc src , opts={}
  wrapper = wrapper_target src, opts
  wrapper.to_target_doc src
end

.wrapper_target(src, opts = {}) ⇒ Object



9
10
11
12
13
# File 'lib/doc_wrapper/base.rb', line 9

def self.wrapper_target src, opts={}
  doc_origem = infer_doc_origem src, opts
  klass_str = klass_name doc_origem, opts
  klass_str.constantize
end