modest_model 0.1.0 → 0.1.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.
- data/README.md +6 -6
- data/lib/modest_model/base.rb +1 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# ModestModel
|
1
|
+
# ModestModel [](https://secure.travis-ci.org/6twenty/modest_model.png])
|
2
2
|
|
3
3
|
## Overview
|
4
4
|
|
5
|
-
Inspired by Crafting Rails Applications
|
5
|
+
Inspired by [Crafting Rails Applications](http://pragprog.com/book/jvrails/crafting-rails-applications), ModestModel provides an ActiveModel-compliant class that allows you to quickly create simple, table-less models. The intended use is to back interactions with external APIs with Ruby-friendly models rather than raw structured data (such as hashes).
|
6
6
|
|
7
7
|
## Example
|
8
8
|
|
9
|
-
json = MyExternalApi.call('/some/path')
|
9
|
+
json = MyExternalApi.call('/some/path.json')
|
10
10
|
attributes_hash = JSON.decode(json)
|
11
11
|
|
12
12
|
# => {'name' => 'Michael', 'email' => 'michael@example.com'}
|
@@ -33,7 +33,7 @@ ModestModel has been tested and works on MRI 1.8.7 and 1.9.2.
|
|
33
33
|
|
34
34
|
### Usage
|
35
35
|
|
36
|
-
Similar to ActiveRecord models, simply create a class which inherits from `ModestModel::Base
|
36
|
+
Similar to ActiveRecord models, simply create a class which inherits from `ModestModel::Base`. You'll need to define some attributes - this is achieved by calling the `attributes` method passing in the attribute names you require:
|
37
37
|
|
38
38
|
class SampleModel < ModestModel::Base
|
39
39
|
attributes :name, :email
|
@@ -51,8 +51,8 @@ ModestModel includes the following ActiveModel modules:
|
|
51
51
|
|
52
52
|
These allow your ModestModel models to act almost the same as an ActiveRecord model, but without the database. You can mass-assign attributes, add validations, add translations, and call familiar methods like `model_name.human`.
|
53
53
|
|
54
|
-
|
54
|
+
ModestModel was extracted from the Mail Form gem described in chapter 2, "Building Models with Active Model", of [Crafting Rails Applications](http://pragprog.com/book/jvrails/crafting-rails-applications) by Jose Valim. This chapter therefore provides an excellent in-depth explanation of the inner workings of ModestModel.
|
55
55
|
|
56
56
|
## Credits
|
57
57
|
|
58
|
-
This code has been derived from Crafting Rails Applications by Jose Valim, so all credit goes to Jose and [Plataforma](http://blog.plataformatec.com.br/) for granting permission to release this gem.
|
58
|
+
This code has been derived from [Crafting Rails Applications](http://pragprog.com/book/jvrails/crafting-rails-applications) by Jose Valim, so all credit goes to Jose and [Plataforma](http://blog.plataformatec.com.br/) for granting permission to release this gem.
|
data/lib/modest_model/base.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modest_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Fulcher
|