Class: Nagare::Context

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Context

Returns a new instance of Context.



112
113
114
# File 'lib/nagare.rb', line 112

def initialize(attributes = {})
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



124
125
126
127
128
129
130
# File 'lib/nagare.rb', line 124

def method_missing(method)
  if @attributes.has_key?(method)
    @attributes.fetch(method)
  else
    super
  end
end

Instance Method Details

#extend(attributes) ⇒ Object



116
117
118
# File 'lib/nagare.rb', line 116

def extend(attributes)
  Context.new(@attributes.merge(attributes))
end

#respond_to?(key, private_methods = false) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/nagare.rb', line 120

def respond_to?(key, private_methods = false)
  @attributes.has_key?(key) || super
end