mini_form 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.projections.json +8 -0
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +5 -0
- data/README.md +4 -4
- data/Rakefile +1 -1
- data/lib/mini_form/model.rb +7 -1
- data/lib/mini_form/version.rb +1 -1
- data/mini_form.gemspec +1 -1
- data/spec/mini_form_spec.rb +7 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af66d71eb698d18223627223fcdd23773c8c44ed
|
4
|
+
data.tar.gz: b230cebf0fca7e3287487ab88c3eeae7b8e98063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6487e2c427e3e427b140d71830f8a54cc180d4a2db00dce7d414171f729aea38a261c400c5487804fa972a4f13d42ee21312c88fc191c324ed6bff3833f568c
|
7
|
+
data.tar.gz: 645b04ee90f9514b74af2e0fecf2cf83f9a15ecd33be71e3849209f4023424f33ac39acad741992cacad0ea19834490f3d12756e78db3c2a05514472a20cb9f3
|
data/.gitignore
CHANGED
data/.projections.json
ADDED
data/.rubocop.yml
CHANGED
@@ -39,6 +39,10 @@ Style/EachWithObject:
|
|
39
39
|
Style/CollectionMethods:
|
40
40
|
Enabled: false
|
41
41
|
|
42
|
+
# Disables "%i-literals should be delimited by [ and ]."
|
43
|
+
Style/PercentLiteralDelimiters:
|
44
|
+
Enabled: false
|
45
|
+
|
42
46
|
# Disables "Use tr instead of gsubs"
|
43
47
|
Performance/StringReplacement:
|
44
48
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/mini_form.
|
2
|
-
[![Code Climate](https://codeclimate.com/github/RStankov/MiniForm.
|
3
|
-
[![Build Status](https://secure.travis-ci.org/RStankov/MiniForm.
|
4
|
-
[![Code coverage](https://coveralls.io/repos/RStankov/MiniForm/badge.
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/mini_form.svg)](http://badge.fury.io/rb/mini_form)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/RStankov/MiniForm.svg)](https://codeclimate.com/github/RStankov/MiniForm)
|
3
|
+
[![Build Status](https://secure.travis-ci.org/RStankov/MiniForm.svg)](http://travis-ci.org/RStankov/MiniForm)
|
4
|
+
[![Code coverage](https://coveralls.io/repos/RStankov/MiniForm/badge.svg?branch=master)](https://coveralls.io/r/RStankov/MiniForm)
|
5
5
|
|
6
6
|
# MiniForm
|
7
7
|
|
data/Rakefile
CHANGED
data/lib/mini_form/model.rb
CHANGED
@@ -140,7 +140,13 @@ module MiniForm
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def attributes(*attributes, delegate: nil, prefix: nil, allow_nil: nil)
|
143
|
-
|
143
|
+
if prefix
|
144
|
+
attribute_names.push(*attributes.map do |name|
|
145
|
+
:"#{prefix == true ? delegate : prefix}_#{name}"
|
146
|
+
end)
|
147
|
+
else
|
148
|
+
attribute_names.push(*attributes)
|
149
|
+
end
|
144
150
|
|
145
151
|
if delegate.nil?
|
146
152
|
attr_accessor(*attributes)
|
data/lib/mini_form/version.rb
CHANGED
data/mini_form.gemspec
CHANGED
data/spec/mini_form_spec.rb
CHANGED
@@ -24,6 +24,8 @@ module MiniForm
|
|
24
24
|
attr_reader :user
|
25
25
|
|
26
26
|
attributes :name, delegate: :user
|
27
|
+
attributes :id, delegate: :user, prefix: true
|
28
|
+
attributes :name, delegate: :user, prefix: 'full'
|
27
29
|
|
28
30
|
def initialize(user)
|
29
31
|
@user = user
|
@@ -140,6 +142,11 @@ module MiniForm
|
|
140
142
|
it 'returns attribute names' do
|
141
143
|
expect(Example.attribute_names).to eq %i(name price)
|
142
144
|
end
|
145
|
+
|
146
|
+
it 'can handle prefixes' do
|
147
|
+
expect(ExampleWithDelegate.attribute_names).to include :user_id
|
148
|
+
expect(ExampleWithDelegate.attribute_names).to include :full_name
|
149
|
+
end
|
143
150
|
end
|
144
151
|
|
145
152
|
describe '#initialize' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radoslav Stankov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -130,6 +130,7 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
|
+
- ".projections.json"
|
133
134
|
- ".rspec"
|
134
135
|
- ".rubocop.yml"
|
135
136
|
- ".travis.yml"
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
version: '0'
|
168
169
|
requirements: []
|
169
170
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.6.13
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Easy to use form objects in Rails projects
|