constantin 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0a1603331c80ac34581be1425b35c378d8de8be39702b01f2bd24a50a3a910d
4
- data.tar.gz: 19512db49405c561624eb7751b99204b868bb072d1021fd1376241afa3fa0718
3
+ metadata.gz: cb52af75a34cd08d2ab154a4d70efe5318b6ce706a355089c23be235ec197409
4
+ data.tar.gz: 2576c5344799bc654068fc1bb4b98b330ba0e863c9633de598f39f7f02d44874
5
5
  SHA512:
6
- metadata.gz: cf8cd5af61151ee94f7ba89cbc6267c4d89f5b5988304c5320d9bf5e0a2c5ac48aec4095a2aaff3f5e11518faca3d5facaef41dc258491bf81b2b23be4d21ca8
7
- data.tar.gz: 2b920a3b467f5d9f03333ede46f9bc73016d8f22dbbe6a965c54be3f4159f99bf3477f066f749136d3bedf3297c91b696a30a6b3eddef9fd17328b335dfb97ff
6
+ metadata.gz: ec0d99930caf38417f83f1ce19296f805d8d18f54ed2f11da71ee329d9912fd093c56117c9fb60b342e8d16cac827d80fe83f58aa781ac4b1fe3b60ba5fd23ee
7
+ data.tar.gz: 41fdcf25eff731ef893fc4e5880110a52d0bc18ca750394f7526295b8065e3dc7c1e2801a4b7c087c694dda1618681f6d0707d32fa3aeb8b5a237f17dd7df770
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # Constantin
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/constantin`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
2
+ A handy way to utilize constants especially on options.
6
3
 
7
4
  ## Installation
8
5
 
@@ -16,13 +13,40 @@ And then execute:
16
13
 
17
14
  $ bundle
18
15
 
19
- Or install it yourself as:
16
+ ## Usage
17
+
18
+ ```ruby
19
+ # app/constants/country.rb
20
+ class Country < Constantin::Constant
21
+ define_options 'US', 'PH', 'JP'
22
+ define_options { NZ: "New Zealand"}
23
+ end
20
24
 
21
- $ gem install constantin
25
+ Country::ALL
26
+ => ['US', 'PH', 'JP', 'New Zealand']
22
27
 
23
- ## Usage
28
+ Country.constants
29
+ => [:US, :PH, :JP, :NZ]
24
30
 
25
- TODO: Write usage instructions here
31
+ Country::US
32
+ => 'US'
33
+ ```
34
+
35
+ Validate field in model against constants
36
+ ```ruby
37
+ class User
38
+ has_options :country, field: address
39
+ end
40
+
41
+ user = User.new
42
+ user.address = "US"
43
+ user.valid?
44
+ => true
45
+
46
+ user.address = "NZ"
47
+ user.valid?
48
+ => false
49
+ ```
26
50
 
27
51
  ## Development
28
52
 
@@ -1,5 +1,5 @@
1
1
  require "constantin/version"
2
- require "constantin/constant"
2
+ require "constantin/option"
3
3
  require "constantin/active_record"
4
4
 
5
5
  module Constantin
@@ -1,5 +1,5 @@
1
1
  module Constantin
2
- class Constant
2
+ class Option
3
3
  # Supports array of strings or hash
4
4
  # ex.
5
5
  # define_options('PH', 'TH', {'USA' => 'US'})
@@ -1,3 +1,3 @@
1
1
  module Constantin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constantin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jude_cali
@@ -87,7 +87,7 @@ files:
87
87
  - constantin.gemspec
88
88
  - lib/constantin.rb
89
89
  - lib/constantin/active_record.rb
90
- - lib/constantin/constant.rb
90
+ - lib/constantin/option.rb
91
91
  - lib/constantin/version.rb
92
92
  homepage: https://github.com/disruptph/constantin
93
93
  licenses: