quarrel 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +32 -1
- data/lib/quarrel/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -16,9 +16,40 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install quarrel
|
18
18
|
|
19
|
+
## Syntax
|
20
|
+
|
21
|
+
Quarrel uses a simple shorthand syntax to define named parameters. You can use any combination of these to specify
|
22
|
+
the named parameters for Quarrel's methods:
|
23
|
+
|
24
|
+
* Required parameter: A symbol ending in an alphanumeric character, ie: `:city` or `:address1`
|
25
|
+
* Optional parameter: A symbol ending with a question mark, ie: `:zip?`
|
26
|
+
* Defaulted parameter: A symbol ending with an equals sign, and followed by its default value, ie: `:country=, "US"`
|
27
|
+
|
19
28
|
## Usage
|
20
29
|
|
21
|
-
|
30
|
+
Using Quarrel is simple. Just require the quarrel gem, and then call the method you need for your use case:
|
31
|
+
|
32
|
+
### Getting values from named parameters
|
33
|
+
|
34
|
+
def foo params
|
35
|
+
city, state, zip, country = Quarrel.values params, :city, :state, :zip?, :country=, "US"
|
36
|
+
end
|
37
|
+
|
38
|
+
### Setting instance variables from named parameters
|
39
|
+
|
40
|
+
def initialize params
|
41
|
+
Quarrel.set_instance_variables self, params, :city, :state, :zip?, :country=, "US"
|
42
|
+
end
|
43
|
+
|
44
|
+
### Checking for unset values from optional parameters
|
45
|
+
|
46
|
+
Quarrel uses a Special Type object to represent unset values for optional parameters. To determine
|
47
|
+
if a value was not supplied for an optional parameter, call the `unset?` method:
|
48
|
+
|
49
|
+
def foo params
|
50
|
+
city, state, zip, country = Quarrel.values params, :city, :state, :zip?, :country=, "US"
|
51
|
+
if Quarrel.unset?(zip) # ...
|
52
|
+
end
|
22
53
|
|
23
54
|
## Contributing
|
24
55
|
|
data/lib/quarrel/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quarrel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
segments:
|
101
101
|
- 0
|
102
|
-
hash: -
|
102
|
+
hash: -2166998906202398430
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
none: false
|
105
105
|
requirements:
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
segments:
|
110
110
|
- 0
|
111
|
-
hash: -
|
111
|
+
hash: -2166998906202398430
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
114
|
rubygems_version: 1.8.25
|