entasis 0.3.0 → 0.3.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.
- data/HISTORY +3 -0
- data/README.md +9 -1
- data/lib/entasis/model.rb +3 -2
- data/lib/entasis/version.rb +1 -1
- data/spec/entasis_spec.rb +9 -0
- metadata +2 -2
data/HISTORY
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
entasis
|
2
|
-
|
2
|
+
=======
|
3
|
+
|
3
4
|
[](http://travis-ci.org/ingemar/entasis)
|
4
5
|
|
5
6
|
Entasis provides a few neat methods for building a basic class. Handy for models without a database.
|
@@ -25,3 +26,10 @@ anon = Person.new
|
|
25
26
|
anon.valid? # => false
|
26
27
|
anon.errors # => {:name=>["can't be blank"]}>
|
27
28
|
```
|
29
|
+
|
30
|
+
|
31
|
+
Contributors
|
32
|
+
------------
|
33
|
+
|
34
|
+
Joshua Davey (jgdavey)
|
35
|
+
Johnny Winn (nurugger07)
|
data/lib/entasis/model.rb
CHANGED
@@ -4,7 +4,8 @@ module Entasis
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
include ActiveModel::Validations
|
7
|
-
|
7
|
+
class_attribute :attribute_names
|
8
|
+
self.attribute_names ||= []
|
8
9
|
self.class_eval 'class UnknownAttributeError < StandardError; end'
|
9
10
|
end
|
10
11
|
|
@@ -14,7 +15,7 @@ module Entasis
|
|
14
15
|
# Takes a list of attribute names
|
15
16
|
#
|
16
17
|
def attributes(*attrs)
|
17
|
-
|
18
|
+
self.attribute_names += attrs.map(&:to_s)
|
18
19
|
|
19
20
|
attr_accessor *attrs
|
20
21
|
end
|
data/lib/entasis/version.rb
CHANGED
data/spec/entasis_spec.rb
CHANGED
@@ -29,6 +29,15 @@ describe "Entasis::Model" do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
describe "subclasses" do
|
33
|
+
let(:hans) { Child.new(:name => 'Hans', :age => "8", :candy => true) }
|
34
|
+
|
35
|
+
it "inherits attributes from the parent" do
|
36
|
+
hans.attributes.should == { "name" => "Hans", "age" => 8, "city" => nil, "candy" => true }
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
32
41
|
context "validations" do
|
33
42
|
describe "#valid?" do
|
34
43
|
it "validates" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: entasis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
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: 2012-
|
12
|
+
date: 2012-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|