Module: Faceter::Coercers Private

Extended by:
Transproc::Registry
Defined in:
lib/faceter/coercers.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Collection of functions to coerce command arguments to node attributes

Class Method Summary collapse

Class Method Details

.create(name = nil, **options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/faceter/coercers.rb', line 47

def self.create(name = nil, **options)
  { name: name, keys: options.fetch(:from) }
end

.exclude(*keys, **options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
44
# File 'lib/faceter/coercers.rb', line 41

def self.exclude(*keys, **options)
  opts = keys.any? ? { only: keys } : options
  { selector: Selector.new(opts) }
end

.field(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
# File 'lib/faceter/coercers.rb', line 52

def self.field(key)
  { key: key }
end

.fold(**options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



57
58
59
# File 'lib/faceter/coercers.rb', line 57

def self.fold(**options)
  { key: options.fetch(:to) }
end

.prefix(prefix, **options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
19
# File 'lib/faceter/coercers.rb', line 14

def self.prefix(prefix, **options)
  filter = options.fetch(:separator) { "_" }
  nested = options.fetch(:nested) { false }
  selector = Selector.new(options) if options[:except] || options[:only]
  { prefix: prefix, separator: filter, nested: nested, selector: selector }
end

.rename(name, **options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
# File 'lib/faceter/coercers.rb', line 62

def self.rename(name, **options)
  { keys: { name => options.fetch(:to) } }
end

.unfold(**options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/faceter/coercers.rb', line 36

def self.unfold(**options)
  { key: options.fetch(:from) }
end

.unwrap(*keys, **options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
# File 'lib/faceter/coercers.rb', line 22

def self.unwrap(*keys, **options)
  key = options.fetch(:from)
  opts = (keys.any? ? { only: keys } : {}).merge(options)
  { key: key, selector: Selector.new(opts) }
end

.wrap(*keys, **options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
33
# File 'lib/faceter/coercers.rb', line 29

def self.wrap(*keys, **options)
  key = options.fetch(:to)
  opts = (keys.any? ? { only: keys } : {}).merge(options)
  { key: key, selector: Selector.new(opts) }
end