Class: AdequateExposure::Exposure

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, name, fetch_block = nil, **options, &block) ⇒ Exposure

Returns a new instance of Exposure.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/adequate_exposure/exposure.rb', line 9

def initialize(controller, name, fetch_block=nil, **options, &block)
  @controller = controller
  @options = options.with_indifferent_access.merge(name: name)

  merge_lambda_option :fetch, fetch_block if fetch_block
  merge_lambda_option :fetch, block if block_given?

  assert_singleton_option :fetch
  assert_singleton_option :from
  assert_incompatible_options_pair :parent, :model
  assert_incompatible_options_pair :parent, :scope
  assert_incompatible_options_pair :find_by, :find

  normalize_options
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



3
4
5
# File 'lib/adequate_exposure/exposure.rb', line 3

def controller
  @controller
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/adequate_exposure/exposure.rb', line 3

def options
  @options
end

Class Method Details

.expose!(*args, &block) ⇒ Object



5
6
7
# File 'lib/adequate_exposure/exposure.rb', line 5

def self.expose!(*args, &block)
  new(*args, &block).expose!
end

Instance Method Details

#expose!Object



25
26
27
28
# File 'lib/adequate_exposure/exposure.rb', line 25

def expose!
  expose_attribute!
  expose_helper_methods!
end