lotus-model 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae1042adba4d02f0e12ad69ccb025061603a3b24
4
- data.tar.gz: 0c976c625163281c1d8e03409f1ff79db9838ba6
3
+ metadata.gz: e2e425209e8c06b8546835d70e26fc450b72ff16
4
+ data.tar.gz: 85e4168062b4a9482250c8da8e76281b60665760
5
5
  SHA512:
6
- metadata.gz: 91017c7d534780cb9dd7004969835762c1185596845ac8b9a968d762af7913709ddfbd17d5b68daea1c6851152a3b45e6135d2b23b65f548619b77f22a5d8ec5
7
- data.tar.gz: 5a40607f634bdea786e3d2f6005d14acc5f27160f01bb6cb0a0f028414a1163bb0612131ba8554cd1264bcfa7086be853054f7e246d55ff17d9797b7ebe83335
6
+ metadata.gz: c701eb730b887a9810364c410b701bc369914b138704b2defc69f32c9be2d0c27708c5b0bf1b9dc4254fd8d9177f08d7bbd4e920f1ac2039aacec914e5574552
7
+ data.tar.gz: 8dba1937a0132e6e6bdd80f531ca66aef8a4391d2549dbccd4ed11049a134c06187b5d4138e8e752fc61683cdd84bc0fcc4f91fc8f8432114efbbcabbcce1865
@@ -1,6 +1,10 @@
1
1
  # Lotus::Model
2
2
  A persistence layer for Lotus
3
3
 
4
+ ## v0.2.1 - 2015-01-12
5
+ ### Added
6
+ - [Luca Guidi] Compatibility between Lotus::Entity and Lotus::Validations
7
+
4
8
  ## v0.2.0 - 2014-12-23
5
9
  ### Added
6
10
  - [Luca Guidi] Introduced file system adapter
@@ -79,8 +79,10 @@ module Lotus
79
79
  # include Lotus::Entity
80
80
  # end
81
81
  def self.included(base)
82
- base.extend ClassMethods
83
- base.send :attr_accessor, :id
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
- self.attributes.merge Lotus::Utils::Kernel.Array(attrs)
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
- attr_accessor *@attributes
146
+ attrs.each do |attr|
147
+ attr_accessor(attr) if define_attribute?(attr)
148
+ end
153
149
  else
154
- @attributes ||= Set.new([:id])
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 *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
- public_send("#{ k }=", v)
185
+ setter = "#{ k }="
186
+ public_send(setter, v) if respond_to?(setter)
181
187
  end
182
188
  end
183
189
 
@@ -3,6 +3,6 @@ module Lotus
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '0.2.0'.freeze
6
+ VERSION = '0.2.1'.freeze
7
7
  end
8
8
  end
@@ -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.0
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: 2014-12-23 00:00:00.000000000 Z
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.2.2
149
+ rubygems_version: 2.4.5
148
150
  signing_key:
149
151
  specification_version: 4
150
152
  summary: A persistence layer for Lotus