polyblock 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2f1beefa1065720b3875460e7991adb6e3f44d8
4
- data.tar.gz: 58b22a123fa170140d9b12dccf1b141b81c2b54d
3
+ metadata.gz: bd1265ea7c1e6b44fe3eff02f5d97b65a72eb623
4
+ data.tar.gz: 5080b1d2528677ec91e26de8fb785459703454ea
5
5
  SHA512:
6
- metadata.gz: b065106b713622cf0962f87ce9c679b81c865e0c012f11108632a834061d591f69952c6bae48f19cf97c2ffbaa2aa84220a828f27a84b340ae2fc503991cf9ef
7
- data.tar.gz: b85689c10dbfc6b7ad3c34061fc3c0b0e21b4ea252d9a023e7efe8239e547d8ed2702b9e608f86f250690610b27c2fc93982364c7ee7f57b0e99642f52a8fa02
6
+ metadata.gz: cc0a82aca881525f1e5248addc80bb311706cdac72c4130a13131b4fceff5fe627dd7f3399a9b2fb7a5f1bc252e3172e3f95a47aefb05ded1b534a449cd7c85c
7
+ data.tar.gz: b98a0db71f5d2783d09bbe8db63aa3cf476f006286f6381d4d928f8017d9e7781af6ca2e1cccf0f1ef97743db93c5215646117c08511a1121382e8b83c353420
@@ -4,14 +4,20 @@ module Polyblock
4
4
  class PolyblocksController < ApplicationController
5
5
 
6
6
  def update
7
- if params.key?(:pbs) && params[:pbs].any?
7
+ if params.key?(:pbs)
8
8
  params[:pbs].each do |i, attrs|
9
- pb_find = Block.where(:id => attrs[:id])
10
- attrs.delete(:id)
11
- if pb_find.any? && pb_find.first.name == attrs[:name]
12
- pb_find.first.update_attributes!(attrs)
9
+ permitted_attrs = attrs.permit(:id, :name, :content, :_destroy)
10
+ id = permitted_attrs.delete :id
11
+ name = permitted_attrs[:name]
12
+ matching_block = if id.present?
13
+ Block.find id.to_i
14
+ elsif name.present?
15
+ Block.find_by :name => name
16
+ end
17
+ if matching_block.present?
18
+ matching_block.update_attributes!(permitted_attrs)
13
19
  else
14
- Block.create! attrs
20
+ Block.create! permitted_attrs
15
21
  end
16
22
  end
17
23
  render :text => "OK!"
@@ -1,3 +1,3 @@
1
1
  module Polyblock
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyblock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - MacKinley Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-27 00:00:00.000000000 Z
11
+ date: 2015-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails