Module: Liquor::External::ClassMethods

Defined in:
lib/liquor/external.rb

Instance Method Summary collapse

Instance Method Details

#deprecate(*args) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/liquor/external.rb', line 15

def deprecate(*args)
  options = {}
  options = args.delete_at(-1) if args[-1].is_a? Hash

  if (missing = [:date, :message] - options.keys).any?
    raise ::ArgumentError, "A call to Liquor::External#deprecate misses " <<
                           "mandatory arguments: #{missing.join(", ")}"
  elsif (extra = options.keys - [:date, :message]).any?
    raise ::ArgumentError, "A call to Liquor::External#deprecate has " <<
                           "extraneous arguments: #{missing.join(", ")}"
  end

  options = {
    date:    Date.parse(options[:date]),
    message: options[:message].to_s
  }.freeze

  args.each do |export|
    @liquor_deprecations[export] = options
  end
end

#export(*methods) ⇒ Object


6
7
8
9
10
11
12
13
# File 'lib/liquor/external.rb', line 6

def export(*methods)
  unless @liquor_exports
    @liquor_exports      = superclass.liquor_exports.dup
    @liquor_deprecations = superclass.liquor_deprecations.dup
  end

  @liquor_exports.merge methods
end