Class: Easyrb::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/easyrb/context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, helpers) ⇒ Context

# Constructor #

#


19
20
21
22
# File 'lib/easyrb/context.rb', line 19

def initialize(context, helpers)
  @context = context
  @helpers = Array(helpers)
end

Instance Attribute Details

#helpersObject (readonly)

# Declarations #

#


11
12
13
# File 'lib/easyrb/context.rb', line 11

def helpers
  @helpers
end

Class Method Details

.[](context, helpers) ⇒ Object

# Class Methods #

#


30
31
32
# File 'lib/easyrb/context.rb', line 30

def self.[](context, helpers)
  new(context, helpers).generate_context
end

Instance Method Details

#generate_contextObject

# Instance Methods #

#


40
41
42
43
44
45
46
# File 'lib/easyrb/context.rb', line 40

def generate_context
  context.tap do |obj|
    helpers.each do |mod|
      obj.extend(mod)
    end
  end
end