Class: Safrano::Expand
- Inherits:
-
ExpandBase
- Object
- ExpandBase
- Safrano::Expand
- Defined in:
- lib/odata/expand.rb
Overview
single expand
Constant Summary collapse
- DEEPH_0 =
used for Sequel eager argument Recursive array to deep hash
- 1,2,3,4
-
–> 1=>{2=>{3=>4}}
- 1
-
–> 1
->(inp) { inp.size > 1 ? { inp[0] => DEEPH_0.call(inp[1..-1]) } : inp[0] }
- DEEPH_1 =
used for building output template Recursive array to deep hash
- 1,2,3,4
-
–> 1=>{2=>{3=>4}}
- 1
-
–> { 1 => {} }
->(inp) { inp.size > 1 ? { inp[0] => DEEPH_1.call(inp[1..-1]) } : { inp[0] => {} } }
- NODESEP =
'/'
Constants inherited from ExpandBase
Safrano::ExpandBase::EMPTYH, Safrano::ExpandBase::EmptyExpand
Instance Attribute Summary collapse
-
#arg ⇒ Object
readonly
sequel eager arg.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #apply_to_dataset(dtcx) ⇒ Object
- #build_arg ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(exstr) ⇒ Expand
constructor
A new instance of Expand.
Methods inherited from ExpandBase
Constructor Details
Instance Attribute Details
#arg ⇒ Object (readonly)
sequel eager arg.
37 38 39 |
# File 'lib/odata/expand.rb', line 37 def arg @arg end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
38 39 40 |
# File 'lib/odata/expand.rb', line 38 def template @template end |
Instance Method Details
#apply_to_dataset(dtcx) ⇒ Object
61 62 63 |
# File 'lib/odata/expand.rb', line 61 def apply_to_dataset(dtcx) Contract.valid(dtcx) end |
#build_arg ⇒ Object
65 66 67 68 69 70 |
# File 'lib/odata/expand.rb', line 65 def build_arg # 'a/b/c/d' ==> {a: {b:{c: :d}}} # 'xy' ==> :xy @arg = DEEPH_0.call(@nodes.map(&:to_sym)) @template = DEEPH_1.call(@nodes) end |
#empty? ⇒ Boolean
72 73 74 |
# File 'lib/odata/expand.rb', line 72 def empty? false end |