Module: DecentExposure

Defined in:
lib/decent_exposure/version.rb,
lib/decent_exposure.rb,
lib/decent_exposure/railtie.rb,
lib/decent_exposure/default_exposure.rb,
lib/decent_exposure/controller_instance_methods.rb

Overview

:nodoc

Defined Under Namespace

Modules: ControllerInstanceMethods, DefaultExposure Classes: Railtie

Constant Summary collapse

VERSION =
"1.2.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_default_exposureObject

Returns the value of attribute _default_exposure.



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

def _default_exposure
  @_default_exposure
end

Instance Method Details

#default_exposure(&block) ⇒ Object



13
14
15
16
# File 'lib/decent_exposure.rb', line 13

def default_exposure(&block)
  self._default_exposure = block if block_given?
  _default_exposure
end

#expose(name, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/decent_exposure.rb', line 18

def expose(name, &block)
  closured_exposure = default_exposure
  define_method name do
    @_resources       ||= {}
    @_resources[name] ||= if block_given?
      instance_eval(&block)
    else
      instance_exec(name, &closured_exposure)
    end
  end
  helper_method name
  hide_action name
end

#inherited(klass) ⇒ Object



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

def inherited(klass)
  closured_exposure = default_exposure
  klass.class_eval do
    default_exposure(&closured_exposure)
  end
  super
end