Class: Fluent::Json::Schema::Lexicon

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/fluent/json/schema/lexicon.rb

Instance Method Summary collapse

Instance Method Details

#combinerObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fluent/json/schema/lexicon.rb', line 20

def combiner
  named = lambda do |definition, name| 
    definition.new(name) 
  end

  optioned = lambda do |definition, name, options| 
    definition.new(name, options) 
  end

  lambda do |api, term, definition, args, block|
    if definition.class.name.demodulize.downcase.to_sym == term
      return api.add(definition.new(*args))
    end

    results = Fluent::Lexicon.collect(
      named.curry.(definition), 
      optioned.curry.(definition)
    ).call(*args)

    block.call(*results) if block.present?
    return api.add(*results)
  end
end

#dictionaryObject



10
11
12
# File 'lib/fluent/json/schema/lexicon.rb', line 10

def dictionary
  Fluent::Lexicon.reflect(Fluent::Json::Schema::Terms)
end

#translatorObject



14
15
16
17
18
# File 'lib/fluent/json/schema/lexicon.rb', line 14

def translator
  lambda do |term|
    term.to_s.singularize.to_sym
  end
end