Class: Safrano::UrlParameters4Coll
Overview
url parameters for a collection expand/select + filter/order
Instance Attribute Summary collapse
#expand, #select
Instance Method Summary
collapse
#check_expand, #check_select
Constructor Details
Returns a new instance of UrlParameters4Coll.
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/odata/url_parameters.rb', line 56
def initialize(dataset, params = {})
super
@jh = @model.join_by_paths_helper if params['$orderby'] || params['$filter']
@params = params
@ordby = OrderBase.factory(@params['$orderby'], @jh)
@filt = FilterBase.factory(@params['$filter'])
@expand = ExpandBase.factory(@params['$expand'], @model)
@select = SelectBase.factory(@params['$select'], @model)
end
|
Instance Attribute Details
#filt ⇒ Object
Returns the value of attribute filt.
53
54
55
|
# File 'lib/odata/url_parameters.rb', line 53
def filt
@filt
end
|
#ordby ⇒ Object
Returns the value of attribute ordby.
54
55
56
|
# File 'lib/odata/url_parameters.rb', line 54
def ordby
@ordby
end
|
Instance Method Details
#apply_expand_to_dataset(dtcx) ⇒ Object
104
105
106
107
108
|
# File 'lib/odata/url_parameters.rb', line 104
def apply_expand_to_dataset(dtcx)
return Contract.valid(dtcx) if @expand.empty?
@expand.apply_to_dataset(dtcx)
end
|
#apply_filter_order_to_dataset(dtcx) ⇒ Object
Warning, the @ordby and @filt objects are coupled by way of the join helper
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/odata/url_parameters.rb', line 111
def apply_filter_order_to_dataset(dtcx)
return Contract.valid(dtcx) if @filt.empty? && @ordby.empty?
@filt.finalize(@jh).if_valid do
dtcx = @jh.dataset(dtcx)
@filt.apply_to_dataset(dtcx).map_result! do |dataset|
dtcx = dataset
dtcx = @ordby.apply_to_dataset(dtcx)
dtcx.select_all(@jh.start_model.table_name)
end
end
end
|
#apply_to_dataset(dtcx) ⇒ Object
98
99
100
101
102
|
# File 'lib/odata/url_parameters.rb', line 98
def apply_to_dataset(dtcx)
apply_expand_to_dataset(dtcx).if_valid do |dataset|
apply_filter_order_to_dataset(dataset)
end
end
|
#check_all ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/odata/url_parameters.rb', line 129
def check_all
return Contract::OK unless @params
check_top.if_valid do
check_skip.if_valid do
check_orderby.if_valid do
check_filter.if_valid do
check_expand.if_valid do
check_select.if_valid do
check_inlinecount
end
end
end
end
end
end
end
|
#check_filter ⇒ Object
87
88
89
|
# File 'lib/odata/url_parameters.rb', line 87
def check_filter
(err = @filt.parse_error?) ? err : Contract::OK
end
|
#check_inlinecount ⇒ Object