has_attributes 0.0.1 → 0.0.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.
- data/History.md +6 -0
- data/README.md +4 -0
- data/lib/has_attributes/version.rb +1 -1
- data/lib/has_attributes.rb +2 -2
- metadata +2 -2
data/History.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
has_attributes is a ruby gem which provides a module for extending your classes with simple methods for creating elegant plain-ruby models.
|
4
4
|
|
5
|
+
```
|
6
|
+
gem install has_attributes
|
7
|
+
```
|
8
|
+
|
5
9
|
## API
|
6
10
|
|
7
11
|
has_attributes delivers the following class and instance methods:
|
data/lib/has_attributes.rb
CHANGED
@@ -38,13 +38,13 @@ module HasAttributes
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def attributes=(attrs)
|
41
|
-
self.class.model_attributes.each {|attr|
|
41
|
+
self.class.model_attributes.each {|attr| public_send((attr.to_s << "=").to_sym, attrs[attr])}
|
42
42
|
attributes
|
43
43
|
end
|
44
44
|
|
45
45
|
def attributes
|
46
46
|
self.class.model_attributes.reduce({}) do |memo, attr|
|
47
|
-
memo.merge(attr =>
|
47
|
+
memo.merge(attr => public_send(attr))
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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-
|
12
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|