madoka 0.0.1 → 0.0.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.
- data/lib/madoka.rb +3 -2
- data/lib/madoka/serializable_model.rb +16 -0
- data/lib/madoka/version.rb +1 -1
- data/spec/madoka/serializable_model_spec.rb +18 -0
- metadata +7 -4
data/lib/madoka.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "madoka/version"
|
2
2
|
|
3
3
|
module Madoka
|
4
|
-
autoload :Model,
|
5
|
-
autoload :
|
4
|
+
autoload :Model, 'madoka/model'
|
5
|
+
autoload :SerializableModel, 'madoka/serializable_model'
|
6
|
+
autoload :ModelInvalid, 'madoka/model_invalid'
|
6
7
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
require 'active_model/model' unless defined?(ActiveModel::Model)
|
3
|
+
require 'active_record/attribute_assignment'
|
4
|
+
require 'active_record/errors'
|
5
|
+
|
6
|
+
module Madoka
|
7
|
+
module SerializableModel
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
include ActiveModel::Model
|
12
|
+
include ActiveModel::Serializers::JSON
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/madoka/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class MadokaSerializableModel
|
4
|
+
include Madoka::SerializableModel
|
5
|
+
|
6
|
+
def serializable_hash(options = nil)
|
7
|
+
{'attribute' => 'value'}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe MadokaSerializableModel do
|
12
|
+
describe '#to_json' do
|
13
|
+
it 'should convert to json string' do
|
14
|
+
MadokaSerializableModel.new.to_json.
|
15
|
+
should == {'attribute' => 'value'}.to_json
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madoka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -158,9 +158,11 @@ files:
|
|
158
158
|
- lib/madoka.rb
|
159
159
|
- lib/madoka/model.rb
|
160
160
|
- lib/madoka/model_invalid.rb
|
161
|
+
- lib/madoka/serializable_model.rb
|
161
162
|
- lib/madoka/version.rb
|
162
163
|
- madoka.gemspec
|
163
164
|
- spec/madoka/model_spec.rb
|
165
|
+
- spec/madoka/serializable_model_spec.rb
|
164
166
|
- spec/spec_helper.rb
|
165
167
|
- spec/support/active_model.rb
|
166
168
|
homepage: https://github.com/ayamomiji/madoka
|
@@ -177,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
179
|
version: '0'
|
178
180
|
segments:
|
179
181
|
- 0
|
180
|
-
hash:
|
182
|
+
hash: 1299015370734063985
|
181
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
184
|
none: false
|
183
185
|
requirements:
|
@@ -186,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
188
|
version: '0'
|
187
189
|
segments:
|
188
190
|
- 0
|
189
|
-
hash:
|
191
|
+
hash: 1299015370734063985
|
190
192
|
requirements: []
|
191
193
|
rubyforge_project:
|
192
194
|
rubygems_version: 1.8.23
|
@@ -195,5 +197,6 @@ specification_version: 3
|
|
195
197
|
summary: A model based on ActiveModel that provides mass assignment with role support.
|
196
198
|
test_files:
|
197
199
|
- spec/madoka/model_spec.rb
|
200
|
+
- spec/madoka/serializable_model_spec.rb
|
198
201
|
- spec/spec_helper.rb
|
199
202
|
- spec/support/active_model.rb
|