static_models 0.2.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/lib/static_models/version.rb +1 -1
- data/static_models.gemspec +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d77b33fce2c3bb1b2547381dbc8a0fe08ec2dec
|
4
|
+
data.tar.gz: 25049e39993a9ab70f4891b9bbe7ef338a4a4039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f110800d4495af904267a5998496b3faa8eade6b086a709e6bdc4dde4ebc46dc2a3b8c89a7a429135decdb3c5e81cf599575e4df156a52e5f5179b79a6d54fb9
|
7
|
+
data.tar.gz: 71378d6f04fe8c2c3be6b80b9f883906f6e1c0c3cc866cdaf9f4f68ceef677a8972984cf5740cbd5a02cf9e2823272e2c5c4cae32a8e1de555a423abad49be13
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# StaticModels
|
2
2
|
|
3
|
-
DRY your
|
3
|
+
DRY your auxiliary singleton enumerations.
|
4
|
+
You know, those "key - value" classes.
|
5
|
+
Use them as associations on a parent model.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -21,7 +23,7 @@ Or install it yourself as:
|
|
21
23
|
## Usage
|
22
24
|
|
23
25
|
```ruby
|
24
|
-
# We're modelling
|
26
|
+
# We're modelling Dogs, each of them has a Breed.
|
25
27
|
# We support a static set of Breeds.
|
26
28
|
|
27
29
|
class Breed
|
@@ -31,7 +33,7 @@ Or install it yourself as:
|
|
31
33
|
# Actually define the breeds we support using a Hash
|
32
34
|
# Keys are the 'id' attribute of each model. Must be Integers.
|
33
35
|
# Values are the 'code' attribute. Must be Symbols, and unique.
|
34
|
-
# If you want your model to have extra attributes, make
|
36
|
+
# If you want your model to have extra attributes, make the value
|
35
37
|
# be an Array of 2 elements: [Symbol, Hash].
|
36
38
|
static_models(
|
37
39
|
1 => :collie,
|
@@ -51,9 +53,9 @@ Or install it yourself as:
|
|
51
53
|
end
|
52
54
|
|
53
55
|
# Definitions can be sparse, no need to set a value for all attributes.
|
54
|
-
Breed.collie.height
|
56
|
+
Breed.collie.height == nil
|
55
57
|
|
56
|
-
# All just returns the ordered collection.
|
58
|
+
# 'All' just returns the ordered collection.
|
57
59
|
Breed.all.should == [
|
58
60
|
Breed.collie,
|
59
61
|
Breed.foxhound,
|
@@ -69,7 +71,7 @@ Or install it yourself as:
|
|
69
71
|
7 => Breed.doberman
|
70
72
|
}
|
71
73
|
|
72
|
-
# You
|
74
|
+
# You point to your StaticModels like an ActiveRecords belongs_to association
|
73
75
|
# Setting a Breed will update a breed_id attribute.
|
74
76
|
class Dog
|
75
77
|
attr_accessor :breed_id
|
data/static_models.gemspec
CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
32
|
spec.add_development_dependency "activerecord", '~> 4.2', '>= 4.2.0'
|
33
|
-
spec.add_development_dependency "sqlite3", "~> 0"
|
33
|
+
spec.add_development_dependency "sqlite3", "~> 1.0", ">= 1.0.0"
|
34
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nubis
|
@@ -98,14 +98,20 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
101
|
+
version: '1.0'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.0.0
|
102
105
|
type: :development
|
103
106
|
prerelease: false
|
104
107
|
version_requirements: !ruby/object:Gem::Requirement
|
105
108
|
requirements:
|
106
109
|
- - "~>"
|
107
110
|
- !ruby/object:Gem::Version
|
108
|
-
version: '0'
|
111
|
+
version: '1.0'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 1.0.0
|
109
115
|
description: "\n Replace your key/value classes with this.\n Define classes
|
110
116
|
with several 'singleton' instances.\n "
|
111
117
|
email:
|