Class: Librarian::Dsl::Target::SourceShortcutDefinitionReceiver

Inherits:
Object
  • Object
show all
Defined in:
lib/librarian/dsl/target.rb

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ SourceShortcutDefinitionReceiver

Returns a new instance of SourceShortcutDefinitionReceiver


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/librarian/dsl/target.rb', line 8

def initialize(target)
  singleton_class = class << self; self end
  singleton_class.class_eval do
    define_method(:source) do |options|
      target.source_from_options(options)
    end
    target.source_types.each do |source_type|
      name = source_type[0]
      define_method(name) do |*args|
        args.push({}) unless Hash === args.last
        target.source_from_params(name, *args)
      end
    end
  end
end