Class: Almodovar::ResourcePresenter::Link::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/almodovar-server/resource_presenter/link.rb

Direct Known Subclasses

JsonSerializer, XmlSerializer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(link, options) ⇒ Serializer

Returns a new instance of Serializer.



44
45
46
47
# File 'lib/almodovar-server/resource_presenter/link.rb', line 44

def initialize(link, options)
  @link = link
  @options = options
end

Instance Attribute Details

Returns the value of attribute link.



42
43
44
# File 'lib/almodovar-server/resource_presenter/link.rb', line 42

def link
  @link
end

#optionsObject (readonly)

Returns the value of attribute options.



42
43
44
# File 'lib/almodovar-server/resource_presenter/link.rb', line 42

def options
  @options
end

Instance Method Details

#dont_expand_link!Object



55
56
57
# File 'lib/almodovar-server/resource_presenter/link.rb', line 55

def dont_expand_link!
  (options[:dont_expand] ||= []) << link.href
end

#expands?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/almodovar-server/resource_presenter/link.rb', line 49

def expands?
  link.expand_resource? && 
  Array(options[:expand]).include?(link.rel) && 
  !Array(options[:dont_expand]).include?(link.href)
end