Class: ContentNetwork::PathParams

Inherits:
Object
  • Object
show all
Defined in:
lib/content_network/path_params.rb

Constant Summary collapse

ATTRS =
i(element_type section_name entry_type entry_id)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element_type: 'Entry', section_name: 'all', entry_type: 'all', entry_id: 'all') ⇒ PathParams

Returns a new instance of PathParams.



11
12
13
14
15
16
# File 'lib/content_network/path_params.rb', line 11

def initialize(element_type: 'Entry', section_name: 'all', entry_type: 'all', entry_id: 'all')
  @element_type = element_type
  @section_name = section_name
  @entry_type = entry_type
  @entry_id = entry_id
end

Class Method Details

.build(params) ⇒ Object



3
4
5
# File 'lib/content_network/path_params.rb', line 3

def self.build(params)
  new(params.slice(*ATTRS))
end

Instance Method Details

#pathObject



18
19
20
# File 'lib/content_network/path_params.rb', line 18

def path
  [@element_type, @section_name, @entry_type, @entry_id].join('/')
end