module Meta2::Strategies

Attributes

config[R]
formats[R]
options[R]

Public Class Methods

new(options) click to toggle source
# File lib/meta2/strategies.rb, line 5
def initialize(options)
  @options  = options
  @config   = Meta2.config
end

Public Instance Methods

detect() click to toggle source
# File lib/meta2/strategies.rb, line 10
def detect
  raise "`detect` method Must be need to overriden"
end

Protected Instance Methods

build_path(prefix) click to toggle source
# File lib/meta2/strategies.rb, line 26
def build_path(prefix)
  path_prefix = prefix.gsub '/', '.'
  '%s.config.parts.%s.%s' % [
    @config.assign_name, path_prefix, @options[:template]
  ]
end
default_formats() click to toggle source
# File lib/meta2/strategies.rb, line 33
def default_formats
  hash = @config.columns.map do |column|
    [column, '%']
  end
  Hash[*hash.flatten]
end
retrieve_parts() { |path| ... } click to toggle source
# File lib/meta2/strategies.rb, line 17
def retrieve_parts
  @options[:prefixes].detect do |prefix|
    path    = build_path prefix
    result  = yield path
    Meta2.debug "part path:#{path} #{result ? 'hit' : 'miss'}"
    result
  end
end