lotus-model 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/lotus/entity.rb +22 -16
- data/lib/lotus/model/version.rb +1 -1
- data/lotus-model.gemspec +2 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2e425209e8c06b8546835d70e26fc450b72ff16
|
4
|
+
data.tar.gz: 85e4168062b4a9482250c8da8e76281b60665760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c701eb730b887a9810364c410b701bc369914b138704b2defc69f32c9be2d0c27708c5b0bf1b9dc4254fd8d9177f08d7bbd4e920f1ac2039aacec914e5574552
|
7
|
+
data.tar.gz: 8dba1937a0132e6e6bdd80f531ca66aef8a4391d2549dbccd4ed11049a134c06187b5d4138e8e752fc61683cdd84bc0fcc4f91fc8f8432114efbbcabbcce1865
|
data/CHANGELOG.md
CHANGED
data/lib/lotus/entity.rb
CHANGED
@@ -79,8 +79,10 @@ module Lotus
|
|
79
79
|
# include Lotus::Entity
|
80
80
|
# end
|
81
81
|
def self.included(base)
|
82
|
-
base.
|
83
|
-
|
82
|
+
base.class_eval do
|
83
|
+
extend ClassMethods
|
84
|
+
attributes :id
|
85
|
+
end
|
84
86
|
end
|
85
87
|
|
86
88
|
module ClassMethods
|
@@ -138,28 +140,31 @@ module Lotus
|
|
138
140
|
# DeletedUser.attributes => #<Set: {:id, :name, :deleted_at}>
|
139
141
|
def attributes(*attrs)
|
140
142
|
if attrs.any?
|
141
|
-
|
142
|
-
|
143
|
-
class_eval <<-END_EVAL, __FILE__, __LINE__
|
144
|
-
def initialize(attributes = {})
|
145
|
-
attributes = Lotus::Utils::Attributes.new(attributes)
|
146
|
-
#{@attributes.map do |a|
|
147
|
-
"@#{a} = attributes.get(:#{a})"
|
148
|
-
end.join("\n") }
|
149
|
-
end
|
150
|
-
END_EVAL
|
143
|
+
attrs = Lotus::Utils::Kernel.Array(attrs)
|
144
|
+
self.attributes.merge attrs
|
151
145
|
|
152
|
-
|
146
|
+
attrs.each do |attr|
|
147
|
+
attr_accessor(attr) if define_attribute?(attr)
|
148
|
+
end
|
153
149
|
else
|
154
|
-
@attributes ||= Set.new
|
150
|
+
@attributes ||= Set.new
|
155
151
|
end
|
156
152
|
end
|
157
153
|
|
154
|
+
# Check if attr_reader define the given attribute
|
155
|
+
#
|
156
|
+
# @since 0.2.1
|
157
|
+
# @api private
|
158
|
+
def define_attribute?(name)
|
159
|
+
name == :id ||
|
160
|
+
!instance_methods.include?(name)
|
161
|
+
end
|
162
|
+
|
158
163
|
protected
|
159
164
|
|
160
165
|
# @see Class#inherited
|
161
166
|
def inherited(subclass)
|
162
|
-
subclass.attributes
|
167
|
+
subclass.attributes(*attributes)
|
163
168
|
super
|
164
169
|
end
|
165
170
|
end
|
@@ -177,7 +182,8 @@ module Lotus
|
|
177
182
|
# @see .attributes
|
178
183
|
def initialize(attributes = {})
|
179
184
|
attributes.each do |k, v|
|
180
|
-
|
185
|
+
setter = "#{ k }="
|
186
|
+
public_send(setter, v) if respond_to?(setter)
|
181
187
|
end
|
182
188
|
end
|
183
189
|
|
data/lib/lotus/model/version.rb
CHANGED
data/lotus-model.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'lotus/model/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'lotus-model'
|
8
8
|
spec.version = Lotus::Model::VERSION
|
9
|
-
spec.authors = ['Luca Guidi']
|
10
|
-
spec.email = ['me@lucaguidi.com']
|
9
|
+
spec.authors = ['Luca Guidi', 'Trung Lê']
|
10
|
+
spec.email = ['me@lucaguidi.com', 'trung.le@ruby-journal.com']
|
11
11
|
spec.summary = %q{A persistence layer for Lotus}
|
12
12
|
spec.description = %q{A persistence framework with entities, repositories, data mapper and query objects}
|
13
13
|
spec.homepage = 'http://lotusrb.org'
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotus-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
|
+
- Trung Lê
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: lotus-utils
|
@@ -90,6 +91,7 @@ description: A persistence framework with entities, repositories, data mapper an
|
|
90
91
|
query objects
|
91
92
|
email:
|
92
93
|
- me@lucaguidi.com
|
94
|
+
- trung.le@ruby-journal.com
|
93
95
|
executables: []
|
94
96
|
extensions: []
|
95
97
|
extra_rdoc_files: []
|
@@ -144,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
146
|
version: '0'
|
145
147
|
requirements: []
|
146
148
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.4.5
|
148
150
|
signing_key:
|
149
151
|
specification_version: 4
|
150
152
|
summary: A persistence layer for Lotus
|