n_attributes 0.2.7
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 +15 -0
- data/Gemfile +4 -0
- data/lib/n_attributes/railtie.rb +12 -0
- data/lib/n_attributes/version.rb +3 -0
- data/lib/n_attributes.rb +50 -0
- data/lib/tasks/n_attributes.rake +8 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDc3OGFmYzg1ZGI2ODQwZjllYjlhZTQ5ODgzMWNlNDYzYzJlMzE2Yw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzY1YWY3NWEwMTkzODZhZWJhNjhkZWRjODc2OTA5NmQyMTU5OTQyOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDA0YTZiMDkyYWU4OWNkNWRjOWI3ODBhNzgyNzY2Y2IwMjUxZmU1YzU0YzQ3
|
10
|
+
YjcyOTQ3MTIxODVmNTVjZTRiODM0OTI3NDdjNmZhZTg5ZGY5NTViYTliZjA3
|
11
|
+
YzJjYTA5ZjFmZmVlNjZlMmQ1MjM5NmFlMWNmNDgzODk1YWFjZDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDllZDAwODA2YzdhMmU3MmUwZGJiNmRjNWRhM2FjZGYzZGQxMDBjMTkwZmZh
|
14
|
+
OGFjMDI5ZDMzZTBiNDY5ZWExYTlmOWU3ZjY4MTJlOTEzMmQ4ZDU4NWI5NTgw
|
15
|
+
NjEzOWJjN2RmOGIxZWY1MTdhNTNlODY4YzU1NjEyMzI1Yjg0OTY=
|
data/Gemfile
ADDED
data/lib/n_attributes.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "n_attributes/version"
|
2
|
+
|
3
|
+
module NAttributes
|
4
|
+
require 'n_attributes/railtie' if defined?(Rails)
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def n_attributes(*args)
|
12
|
+
args.each do |arg|
|
13
|
+
serialize %(:#{arg})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def method_missing(meth, *args, &block)
|
19
|
+
if meth.present?
|
20
|
+
run_split(meth, *args, &block)
|
21
|
+
else
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_split(meth, *args, &block)
|
27
|
+
meth = meth.to_s
|
28
|
+
attribute, key = meth.gsub('=', '').split('_')
|
29
|
+
if args[0].nil?
|
30
|
+
get_key_value(attribute, key)
|
31
|
+
else
|
32
|
+
set_key_pair(attribute, key, args[0])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_key_pair(field, key, value)
|
37
|
+
if self.send(field).nil?
|
38
|
+
self.send(field+ '=', Hash[key, value].to_s)
|
39
|
+
else
|
40
|
+
self.send(field+ '=', eval(self.send(field)).merge(Hash[key, value]).to_s)
|
41
|
+
end
|
42
|
+
self.save
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_key_value(field, key)
|
46
|
+
if key.present?
|
47
|
+
eval(self.send(field))[key]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: n_attributes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sohair Ahmad
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Creates a field inside a model that allows you to store arbitrary n number
|
42
|
+
of attributes against a specified field.
|
43
|
+
email:
|
44
|
+
- sohair.ahmad@square63.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- Gemfile
|
50
|
+
- lib/n_attributes.rb
|
51
|
+
- lib/n_attributes/railtie.rb
|
52
|
+
- lib/n_attributes/version.rb
|
53
|
+
- lib/tasks/n_attributes.rake
|
54
|
+
homepage: https://github.com/Square63/n_attributes
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project: n_attributes
|
74
|
+
rubygems_version: 2.4.3
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Creates a field inside a model that allows you to store arbitrary n number
|
78
|
+
of attributes against a specified field.
|
79
|
+
test_files: []
|