static_models 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/static_models.rb +10 -3
- data/lib/static_models/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ef1da11476c36cfa1b806d8c078837de90a0421
|
4
|
+
data.tar.gz: f14b9af0d4b9e25c26e60d5f21710b97c905dbb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d67bfd2ea2c4c35ecfa0755e21d27d629c346d5a938f91346a28b10d39e440888b4875a13f2cb0a06c913e5420f6d53e0849d2738e5d24997beebceb6e8738f6
|
7
|
+
data.tar.gz: a615411976c3426ff235d8112a64edd149d3250cee51ab18313935980fb04dc6f2d019a8a8b252abcfc40874f05f0bc936453b3e82536d9a41b5de03af254a88
|
data/lib/static_models.rb
CHANGED
@@ -7,15 +7,22 @@ module StaticModels
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do |i|
|
10
|
-
cattr_accessor :values, :
|
10
|
+
cattr_accessor :values, :primary_key, :code_column
|
11
|
+
attr_accessor :attributes
|
11
12
|
|
12
13
|
def initialize(attributes)
|
14
|
+
self.attributes = attributes
|
13
15
|
attributes.each{|name,value| send("#{name}=", value) }
|
14
16
|
end
|
15
17
|
|
16
18
|
def name; send(self.class.code_column); end
|
17
19
|
def to_s; name.to_s; end
|
18
|
-
def to_i; send(self.class.
|
20
|
+
def to_i; send(self.class.primary_key); end
|
21
|
+
|
22
|
+
# Ugly hack to make this compatible with AR validatinos.
|
23
|
+
# It's safe to assume a StaticModel is always valid and never destroyed.
|
24
|
+
def marked_for_destruction?; false; end
|
25
|
+
def valid?; true; end
|
19
26
|
end
|
20
27
|
|
21
28
|
class_methods do
|
@@ -58,7 +65,7 @@ module StaticModels
|
|
58
65
|
end
|
59
66
|
|
60
67
|
attr_accessor *columns
|
61
|
-
self.
|
68
|
+
self.primary_key = columns[0]
|
62
69
|
self.code_column = columns[1]
|
63
70
|
|
64
71
|
self.values = {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nubis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|