Class: Safrano::NilNavigationAttribute
- Inherits:
-
Object
- Object
- Safrano::NilNavigationAttribute
- Includes:
- NavigationInfo, Transitions
- Defined in:
- lib/odata/navigation_attribute.rb
Overview
Represents a named but nil-valued navigation-attribute of an Entity (usually resulting from a NULL FK db value)
Defined Under Namespace
Modules: Transitions
Constant Summary
Constants included from Transitions
Transitions::ALLOWED_TRANSITIONS
Instance Attribute Summary
Attributes included from NavigationInfo
#nav_name, #nav_parent, #navattr_reflection
Instance Method Summary collapse
-
#==(other) ⇒ Object
for testing purpose (assert_equal …).
-
#initialize ⇒ NilNavigationAttribute
constructor
A new instance of NilNavigationAttribute.
- #odata_get(req) ⇒ Object
-
#odata_post(req) ⇒ Object
create the nav.
-
#odata_put(req) ⇒ Object
create the nav.
-
#to_odata_json ⇒ Object
empty output as OData json (v2).
Methods included from Transitions
#allowed_transitions, #transition_end, #transition_value
Methods included from Transitions::GetNextTrans::BySimpleDetect
Methods included from NavigationInfo
Constructor Details
#initialize ⇒ NilNavigationAttribute
Returns a new instance of NilNavigationAttribute.
81 82 83 |
# File 'lib/odata/navigation_attribute.rb', line 81 def initialize @allowed_transitions = ALLOWED_TRANSITIONS end |
Instance Method Details
#==(other) ⇒ Object
for testing purpose (assert_equal …)
118 119 120 |
# File 'lib/odata/navigation_attribute.rb', line 118 def ==(other) (@nav_parent == other.nav_parent) && (@nav_name == other.nav_name) end |
#odata_get(req) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/odata/navigation_attribute.rb', line 86 def odata_get(req) if req.walker.media_value Safrano::ErrorNotFound.odata_get elsif req.accept?(APPJSON) [200, EMPTY_HASH, to_odata_json(service: req.service)] else # TODO: other formats 415 end end |
#odata_post(req) ⇒ Object
create the nav. entity
97 98 99 100 101 102 |
# File 'lib/odata/navigation_attribute.rb', line 97 def odata_post(req) # delegate to the class method @nav_klass.odata_create_entity_and_relation(req, @navattr_reflection, @nav_parent) end |
#odata_put(req) ⇒ Object
create the nav. entity
105 106 107 108 109 110 |
# File 'lib/odata/navigation_attribute.rb', line 105 def odata_put(req) # delegate to the class method @nav_klass.odata_create_entity_and_relation(req, @navattr_reflection, @nav_parent) end |
#to_odata_json ⇒ Object
empty output as OData json (v2)
113 114 115 |
# File 'lib/odata/navigation_attribute.rb', line 113 def to_odata_json(*) { 'd' => EMPTY_HASH }.to_json end |