Module: Monolens::Lens

Includes:
FetchSupport
Included in:
Array::Compact, Array::Join, Array::Map, Check::NotEmpty, Coerce::Array, Coerce::Date, Coerce::DateTime, Coerce::Integer, Coerce::String, Core::Chain, Core::Dig, Core::Digs, Core::Literal, Core::Mapping, File, Object::Allbut, Object::Extend, Object::Keys, Object::Merge, Object::Rename, Object::Select, Object::Transform, Object::Values, Skip::Null, Str::Downcase, Str::NullIfEmpty, Str::Split, Str::Strip, Str::Upcase
Defined in:
lib/monolens/lens.rb,
lib/monolens/lens/options.rb,
lib/monolens/lens/location.rb,
lib/monolens/lens/signature.rb,
lib/monolens/lens/fetch_support.rb,
lib/monolens/lens/signature/missing.rb

Defined Under Namespace

Modules: ClassMethods, FetchSupport Classes: Location, Options, Signature

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FetchSupport

#fetch_on

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



29
30
31
# File 'lib/monolens/lens.rb', line 29

def options
  @options
end

Class Method Details

.included(by) ⇒ Object



18
19
20
# File 'lib/monolens/lens.rb', line 18

def self.included(by)
  by.extend(ClassMethods)
end

Instance Method Details

#fail!(msg, world) ⇒ Object



31
32
33
34
# File 'lib/monolens/lens.rb', line 31

def fail!(msg, world)
  location = world[:location]&.to_a || []
  raise Monolens::LensError.new(msg, location)
end

#initialize(options, registry) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
# File 'lib/monolens/lens.rb', line 22

def initialize(options, registry)
  raise ArgumentError if options.nil?
  raise ArgumentError unless registry.is_a?(Registry)
  raise ArgumentError, "Missing signature on #{self.class}" unless self.class.signature

  @options = Options.new(options, registry, self.class.signature)
end