freeskimer 0.1.0 → 0.1.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/lib/freeskimer/model_additions.rb +9 -8
- data/lib/freeskimer/version.rb +1 -1
- metadata +2 -2
@@ -2,17 +2,18 @@ module Freeskimer
|
|
2
2
|
module ModelAdditions
|
3
3
|
def freeskim(att, options)
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# Validates arguments
|
6
|
+
raise "'to' attribitute is missing" unless options[:to]
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
# Define get method
|
9
|
+
send :define_method, att do
|
10
|
+
tmp = JSON.parse(send(options[:to]).to_s) if send(options[:to])
|
11
|
+
tmp[att.to_s] if tmp and tmp[att.to_s]
|
12
|
+
end
|
13
13
|
|
14
|
-
|
14
|
+
# Define set method
|
15
15
|
send :define_method, "#{att}=" do |value|
|
16
|
+
value = yield(value) if block_given?
|
16
17
|
tmp = {}
|
17
18
|
tmp = JSON.parse send options[:to] if send options[:to]
|
18
19
|
tmp[att] = value
|
data/lib/freeskimer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freeskimer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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:
|
12
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|