Class: Grape::Entity::Exposure::BlockExposure

Inherits:
Base
  • Object
show all
Defined in:
lib/grape_entity/exposure/block_exposure.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attribute, #conditions, #documentation, #for_merge, #is_safe

Instance Method Summary collapse

Methods inherited from Base

#attr_path, #conditional?, #conditions_met?, #deep_complex_nesting?, #dup_args, #initialize, #key, #nesting?, new, #serializable_value, #should_expose?, #should_return_key?, #valid_value, #with_attr_path

Constructor Details

This class inherits a constructor from Grape::Entity::Exposure::Base

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block


7
8
9
# File 'lib/grape_entity/exposure/block_exposure.rb', line 7

def block
  @block
end

Instance Method Details

#==(other) ⇒ Object


17
18
19
# File 'lib/grape_entity/exposure/block_exposure.rb', line 17

def ==(other)
  super && @block == other.block
end

#dupObject


13
14
15
# File 'lib/grape_entity/exposure/block_exposure.rb', line 13

def dup
  super(&@block)
end

#setup(&block) ⇒ Object


25
26
27
# File 'lib/grape_entity/exposure/block_exposure.rb', line 25

def setup(&block)
  @block = block
end

#valid?(_entity) ⇒ Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/grape_entity/exposure/block_exposure.rb', line 21

def valid?(_entity)
  true
end

#value(entity, options) ⇒ Object


9
10
11
# File 'lib/grape_entity/exposure/block_exposure.rb', line 9

def value(entity, options)
  entity.exec_with_object(options, &@block)
end