Module: Her::Model::Paths::ClassMethods
- Defined in:
- lib/castle-her/model/paths.rb
Instance Method Summary collapse
-
#collection_path(path = nil) ⇒ Object
Defines a custom collection path for the resource.
-
#primary_key(value = nil) ⇒ Object
Define the primary key field that will be used to find and save records.
-
#resource_path(path = nil) ⇒ Object
Defines a custom resource path for the resource.
Instance Method Details
#collection_path(path = nil) ⇒ Object
Defines a custom collection path for the resource
48 49 50 51 52 53 54 55 |
# File 'lib/castle-her/model/paths.rb', line 48 def collection_path(path = nil) if path.nil? @_her_collection_path ||= root_element.to_s.pluralize else @_her_collection_path = path @_her_resource_path = "#{path}/:id" end end |
#primary_key(value = nil) ⇒ Object
Define the primary key field that will be used to find and save records
32 33 34 35 36 37 38 39 |
# File 'lib/castle-her/model/paths.rb', line 32 def primary_key(value = nil) @_her_primary_key ||= begin superclass.primary_key if superclass.respond_to?(:primary_key) end return @_her_primary_key unless value @_her_primary_key = value.to_sym end |
#resource_path(path = nil) ⇒ Object
Defines a custom resource path for the resource
Note that, if used in combination with resource_path, you may specify either the real primary key or the string ‘:id’. For example:
80 81 82 83 84 85 86 |
# File 'lib/castle-her/model/paths.rb', line 80 def resource_path(path = nil) if path.nil? @_her_resource_path ||= "#{root_element.to_s.pluralize}/:id" else @_her_resource_path = path end end |