Module: Neo::Rails::Exposure

Extended by:
ActiveSupport::Concern
Defined in:
lib/neo/rails/exposure.rb,
lib/neo/rails/exposure/errors.rb,
lib/neo/rails/exposure/exposures.rb

Overview

A really simple version of exposing variables to the view. Bases on attr_reader and helper_method.

Defined Under Namespace

Modules: ClassMethods Classes: Exposures, UndeclaredVariableError

Instance Method Summary collapse

Instance Method Details

#expose(key, value = nil) ⇒ Object

Expose an assign at the instance level.

If the value is given with a block, just execute the block if a value was not set yet.

Raise UndeclaredVariableError if access variable wasn’t declared before.



43
44
45
46
# File 'lib/neo/rails/exposure.rb', line 43

def expose(key, value=nil)
  value = yield if block_given?
  self.exposures[key] = value
end

#exposuresObject



16
17
18
# File 'lib/neo/rails/exposure.rb', line 16

def exposures
  @exposures ||= Exposures.new(self.class.exposure_names)
end