welo 0.0.6 → 0.0.7

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.
data/Rakefile CHANGED
@@ -25,6 +25,7 @@ spec = Gem::Specification.new do |s|
25
25
  'lib/welo/core/link.rb',
26
26
  'lib/welo/core/matcher.rb',
27
27
  'lib/welo/core/nesting.rb',
28
+ 'lib/welo/core/observation.rb',
28
29
  'lib/welo/core/perspective.rb',
29
30
  'lib/welo/base/resource.rb',
30
31
  ]
data/TODO CHANGED
@@ -1,8 +1,7 @@
1
- * Relationships
2
- - we have :one, :many, we should be able to have, exactly_four, or one_per_foo
3
- * Epitheting vs. Nesting vs. Identifying
4
- - remove alias from Relationship and create a similar Epiteth object?
5
1
  * Embeddings
6
- - recursively embedded datastructures?
7
- - how to work with perspectives?
8
- * ResourceProxy
2
+ - merge the branch
3
+ - use the complex serialization overhead only when needed loaded
4
+ * Observations
5
+ - make them more useful
6
+ * Proxies
7
+ - a class like observations
@@ -0,0 +1,35 @@
1
+
2
+ module Welo
3
+ ObservationStruct = Class.new(Struct) do
4
+ class << self
5
+ attr_accessor :maker, :perspective
6
+ def for_hash(hash)
7
+ vals = members.map do |k|
8
+ hash[k]
9
+ end
10
+ self.new(*vals)
11
+ end
12
+ end
13
+ end
14
+
15
+ class ObservationMaker
16
+ attr_accessor :resource, :structures
17
+ def initialize(res=nil)
18
+ @resource = res
19
+ @structures = {}
20
+ end
21
+
22
+ def structure(name=:default, &blk)
23
+ @structures[name] ||= create_structure!(name, &blk)
24
+ end
25
+
26
+ def create_structure!(name, &blk)
27
+ persp = resource.perspective(name)
28
+ raise ArgumentError.new("no such perspective: #{name} for #{resource}") unless persp
29
+ st = ObservationStruct.new(*persp.fields, &blk)
30
+ st.maker = self
31
+ st.perspective = name
32
+ st
33
+ end
34
+ end
35
+ end
data/lib/welo.rb CHANGED
@@ -1,8 +1,9 @@
1
1
 
2
2
  module Welo
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  AUTHORS = ['crapooze']
5
5
  WEBSITE = "http://github.com/crapooze/welo"
6
6
  LICENCE = "MIT"
7
7
  autoload :Resource, 'welo/base/resource'
8
+ autoload :ObservationMaker, 'welo/core/observation'
8
9
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: welo
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 6
9
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
10
11
  platform: ruby
11
12
  authors:
12
13
  - crapooze
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-02-14 00:00:00 +01:00
18
+ date: 2011-03-03 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -36,6 +37,7 @@ files:
36
37
  - lib/welo/core/link.rb
37
38
  - lib/welo/core/matcher.rb
38
39
  - lib/welo/core/nesting.rb
40
+ - lib/welo/core/observation.rb
39
41
  - lib/welo/core/perspective.rb
40
42
  - lib/welo/base/resource.rb
41
43
  has_rdoc: true
@@ -52,6 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
54
  requirements:
53
55
  - - ">="
54
56
  - !ruby/object:Gem::Version
57
+ hash: 3
55
58
  segments:
56
59
  - 0
57
60
  version: "0"
@@ -60,6 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
63
  requirements:
61
64
  - - ">="
62
65
  - !ruby/object:Gem::Version
66
+ hash: 3
63
67
  segments:
64
68
  - 0
65
69
  version: "0"