Class: Obviews::ExposedAssigns

Inherits:
Hash
  • Object
show all
Defined in:
lib/obviews/exposed_assigns.rb

Instance Method Summary collapse

Constructor Details

#initialize(object, exposed_methods) ⇒ ExposedAssigns

Returns a new instance of ExposedAssigns.



3
4
5
6
7
8
9
10
# File 'lib/obviews/exposed_assigns.rb', line 3

def initialize object, exposed_methods
  @exposed_methods = exposed_methods
  super() do |assigns, key|
    if @exposed_methods.include? key.to_sym
      assigns[key] = object.send(key)
    end
  end
end

Instance Method Details

#inspectObject



16
17
18
# File 'lib/obviews/exposed_assigns.rb', line 16

def inspect
  "#<#{self.class}: @exposed_methods: (#{@exposed_methods.inspect}), hash: #{super}>"
end

#keysObject



12
13
14
# File 'lib/obviews/exposed_assigns.rb', line 12

def keys
  super + @exposed_methods
end