Class: Marameters::Sourcers::Readers::Any

Inherits:
Object
  • Object
show all
Defined in:
lib/marameters/sourcers/readers/any.rb

Overview

Reads source code of callable from disk or memory.

Instance Method Summary collapse

Constructor Details

#initialize(parser: RubyVM::InstructionSequence, disk: Disk, memory: Memory) ⇒ Any

Returns a new instance of Any.



8
9
10
11
12
13
# File 'lib/marameters/sourcers/readers/any.rb', line 8

def initialize parser: RubyVM::InstructionSequence, disk: Disk, memory: Memory
  @parser = parser
  @disk = disk
  @memory = memory
  freeze
end

Instance Method Details

#call(callable) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/marameters/sourcers/readers/any.rb', line 15

def call callable
  instructions = parser.of callable

  fail StandardError, "Unable to load source for: #{callable.inspect}." unless instructions

  instructions.absolute_path ? disk.call(instructions) : memory.call(instructions)
end