Class: ActionController::Resources::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller/resources.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entities, options) ⇒ Resource

Returns a new instance of Resource.



9
10
11
12
13
14
15
16
17
18
# File 'lib/action_controller/resources.rb', line 9

def initialize(entities, options)
  @plural   = entities
  @singular = options[:singular] || plural.to_s.singularize
  
  @options = options

  arrange_actions
  add_default_actions
  set_prefixes
end

Instance Attribute Details

#collection_methodsObject (readonly)

Returns the value of attribute collection_methods.



4
5
6
# File 'lib/action_controller/resources.rb', line 4

def collection_methods
  @collection_methods
end

#member_methodsObject (readonly)

Returns the value of attribute member_methods.



4
5
6
# File 'lib/action_controller/resources.rb', line 4

def member_methods
  @member_methods
end

#name_prefixObject (readonly)

Returns the value of attribute name_prefix.



5
6
7
# File 'lib/action_controller/resources.rb', line 5

def name_prefix
  @name_prefix
end

#new_methodsObject (readonly)

Returns the value of attribute new_methods.



4
5
6
# File 'lib/action_controller/resources.rb', line 4

def new_methods
  @new_methods
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/action_controller/resources.rb', line 7

def options
  @options
end

#path_prefixObject (readonly)

Returns the value of attribute path_prefix.



5
6
7
# File 'lib/action_controller/resources.rb', line 5

def path_prefix
  @path_prefix
end

#pluralObject (readonly)

Returns the value of attribute plural.



6
7
8
# File 'lib/action_controller/resources.rb', line 6

def plural
  @plural
end

#singularObject (readonly)

Returns the value of attribute singular.



6
7
8
# File 'lib/action_controller/resources.rb', line 6

def singular
  @singular
end

Instance Method Details

#controllerObject



20
21
22
# File 'lib/action_controller/resources.rb', line 20

def controller
  (options[:controller] || plural).to_s
end

#member_pathObject



32
33
34
# File 'lib/action_controller/resources.rb', line 32

def member_path
  "#{path}/:id"
end

#nesting_path_prefixObject



36
37
38
# File 'lib/action_controller/resources.rb', line 36

def nesting_path_prefix
  "#{path}/:#{singular}_id"
end

#new_pathObject



28
29
30
# File 'lib/action_controller/resources.rb', line 28

def new_path
  "#{path}/new"
end

#pathObject



24
25
26
# File 'lib/action_controller/resources.rb', line 24

def path
  "#{path_prefix}/#{plural}"
end