Class: Grape::Entity::Exposure::RepresentExposure
- Inherits:
-
Base
- Object
- Base
- Grape::Entity::Exposure::RepresentExposure
show all
- Defined in:
- lib/grape_entity/exposure/represent_exposure.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#attribute, #conditions, #documentation, #for_merge, #is_safe, #override
Instance Method Summary
collapse
Methods inherited from Base
#attr_path, #conditional?, #conditions_met?, #deep_complex_nesting?, #dup, #initialize, #key, #nesting?, new, #override?, #serializable_value, #should_expose?, #should_return_key?, #valid_value, #with_attr_path
Instance Attribute Details
#subexposure ⇒ Object
Returns the value of attribute subexposure.
7
8
9
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 7
def subexposure
@subexposure
end
|
#using_class_name ⇒ Object
Returns the value of attribute using_class_name.
7
8
9
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 7
def using_class_name
@using_class_name
end
|
Instance Method Details
#==(other) ⇒ Object
19
20
21
22
23
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 19
def ==(other)
super &&
@using_class_name == other.using_class_name &&
@subexposure == other.subexposure
end
|
#dup_args ⇒ Object
15
16
17
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 15
def dup_args
[*super, using_class_name, subexposure]
end
|
#setup(using_class_name, subexposure) ⇒ Object
9
10
11
12
13
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 9
def setup(using_class_name, subexposure)
@using_class = nil
@using_class_name = using_class_name
@subexposure = subexposure
end
|
#using_class ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 34
def using_class
@using_class ||= if @using_class_name.respond_to? :constantize
@using_class_name.constantize
else
@using_class_name
end
end
|
#valid?(entity) ⇒ Boolean
30
31
32
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 30
def valid?(entity)
@subexposure.valid? entity
end
|
#value(entity, options) ⇒ Object
25
26
27
28
|
# File 'lib/grape_entity/exposure/represent_exposure.rb', line 25
def value(entity, options)
new_options = options.for_nesting(key(entity))
using_class.represent(@subexposure.value(entity, options), new_options)
end
|