Class: Grape::Entity::Exposure::FormatterBlockExposure

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

Instance Attribute Summary collapse

Attributes inherited from Base

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

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Attribute Details

#format_withObject (readonly)

Returns the value of attribute format_with.



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

def format_with
  @format_with
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/grape_entity/exposure/formatter_block_exposure.rb', line 15

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

#dupObject



11
12
13
# File 'lib/grape_entity/exposure/formatter_block_exposure.rb', line 11

def dup
  super(&@format_with)
end

#setup(&format_with) ⇒ Object



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

def setup(&format_with)
  @format_with = format_with
end

#value(entity, _options) ⇒ Object



19
20
21
# File 'lib/grape_entity/exposure/formatter_block_exposure.rb', line 19

def value(entity, _options)
  entity.exec_with_attribute(attribute, &@format_with)
end