Class: Neo::Rails::Exposure::Exposures

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/neo/rails/exposure/exposures.rb

Overview

Stores the concrete exposures per request

Instance Method Summary collapse

Constructor Details

#initialize(names) ⇒ Exposures

Returns a new instance of Exposures.



13
14
15
16
# File 'lib/neo/rails/exposure/exposures.rb', line 13

def initialize(names)
  @names = names
  @store = Hash.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/neo/rails/exposure/exposures.rb', line 23

def method_missing(method_name, *args)
  if exposed?(method_name)
    @store[method_name]
  else
    super
  end
end

Instance Method Details

#[]=(key, value) ⇒ Object



18
19
20
21
# File 'lib/neo/rails/exposure/exposures.rb', line 18

def []=(key, value)
  raise UndeclaredVariableError unless @names.include?(key)
  @store[key] = value
end