omf_sfa 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,7 +98,7 @@ module OMF::SFA::Resource
98
98
  # end
99
99
  # end
100
100
 
101
- def self.prop_all(query, resource_class = nil)
101
+ def self.prop_all(query, opts = {}, resource_class = nil)
102
102
  i = 0
103
103
  where = query.map do |pn, v|
104
104
  h = _analyse_value(v)
@@ -117,7 +117,10 @@ module OMF::SFA::Resource
117
117
  table = storage_names[:default]
118
118
  from = i.times.map {|j| "#{table} AS p#{j}" }
119
119
  from << "omf_sfa_resource_o_resources AS r" # TODO: Shouldn't hard-code that
120
- q = "SELECT r.id, r.type, r.uuid, r.name FROM #{from.join(', ')} WHERE #{where.join(' AND ')};"
120
+ q = "SELECT DISTINCT r.id, r.type, r.uuid, r.name FROM #{from.join(', ')} WHERE #{where.join(' AND ')};"
121
+ if l = opts[:limit]
122
+ q += " LIMIT #{l} OFFSET #{opts[:offset] || 0}"
123
+ end
121
124
  debug "prop_all q: #{q}"
122
125
  res = repository(:default).adapter.select(q)
123
126
  ores = res.map do |qr|
@@ -284,6 +287,7 @@ module OMF::SFA::Resource
284
287
  p = OProperty.create(name: @name, o_resource: @resource)
285
288
  if @on_set_block
286
289
  val = @on_set_block.call(val)
290
+ return if val.nil? #
287
291
  end
288
292
  p.value = val
289
293
  self
@@ -145,6 +145,7 @@ module OMF::SFA::Resource
145
145
  define_method "#{name}=" do |v|
146
146
  if sf = opts[:set_filter]
147
147
  v = self.send(sf, v)
148
+ return if v.nil? #
148
149
  end
149
150
  return if (old = oproperty_get(name)) == v
150
151
  oproperty_set(name, v)
@@ -166,8 +167,11 @@ module OMF::SFA::Resource
166
167
  end
167
168
  end
168
169
 
169
- def self.prop_all(query)
170
- OProperty.prop_all(query, self)
170
+ # param opts :limit
171
+ # param opts :offset
172
+ #
173
+ def self.prop_all(query, opts = {})
174
+ OProperty.prop_all(query, opts, self)
171
175
  end
172
176
 
173
177
  # Clone this resource this resource. However, the clone will have a unique UUID
@@ -1,4 +1,4 @@
1
1
  module OMF; module SFA
2
2
  #VERSION = "6.0.0.pre.1"
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.2"
4
4
  end; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_sfa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-16 00:00:00.000000000 Z
12
+ date: 2014-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest