Giter Club home page Giter Club logo

modis's Introduction

Code Climate Test Coverage

Modis

ActiveModel + Redis with the aim to mimic ActiveRecord where possible.

Requirements

Modis 4.0+ supports Rails 5.2 and higher, including Rails 6.1, as well as Ruby 2.3 and above, including Ruby 3.0. Tests are also being run with JRuby. For details please check the current CI setup.

For releases supporting older Rails versions such as 4.2-5.1 please check out the 3.x releases.

Installation

Add this line to your application's Gemfile:

gem 'modis'

And then execute:

$ bundle

Or install it yourself as:

$ gem install modis

Usage

class MyModel
  include Modis::Model
  attribute :name, :string
  attribute :age, :integer
end

MyModel.create!(name: 'Ian', age: 28)

all index

Modis, by default, creates an all index in redis in which it stores all the IDs for records created. As a result, a large amount of memory will be consumed if many ids are stored. The all index functionality can be turned off by using enable_all_index

class MyModel
  include Modis::Model
  enable_all_index false
end

By disabling the all index functionality, the IDs of each record created won't be saved. As a side effect, using all finder method will raise a IndexError exception as we would not have enough information to fetch all records. See #7 for more context.

Supported Features

TODO.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

modis's People

Contributors

aried3r avatar benlangfeld avatar dmytrostepaniuk avatar dsantosmerino avatar fdocr avatar garettarrowood avatar ileitch avatar jas14 avatar justinhoward avatar nattfodd avatar rofreg avatar sxdx avatar tonkpils avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modis's Issues

difficult to persist after making changes to part of a hash attribute

I'm persisting a hash attribute and I would like to make changes to parts of the hash and persist them -- however making changes to just part of a hash doesn't mark the model as changed.

The only way I found to do this so far is to serialize and un-serialize with json -- which decreases performance.

I am looking at the Modis code and it seems it's not responsible for maintaining the changed state.

A simple example of the issue:

class Book
  include Modis::Model
  attribute :pages, :integer
  attribute :desc, :hash
end


b1 = Book.create!(:pages => 100, :desc => { :a => 'good' })
=> #<Book:0x007ffdd7f74bd0

b1.pages = 99
=> 99

b1.changed?
=> true

b1.save
=> true

b1.changed?
=> false

b1.desc = { :a => 'very good' }
=> {:a=>"very good"}

b1.changed?
=> true

b1.save
=> true

b1.changed?
=> false

b1.desc[:a] = 'super good'
=> "super good"

b1.desc
=> {:a=>"super good"}

b1.changed?
=> false

b1.desc = JSON(b1.desc.to_json)
=> {"a"=>"super good"}

b1.changed?
=> true

Modis Memory Leak

Looking into memory leak issues with Rpush, which uses Modis for Redis storage, it seems like Modis has a memory leak issue. The memory heap dump below indicates the top two memory allocations are from Modis: (multiple heap dumps were done after GC.start which enforces a garbage cleaning, and the memory used by these lines has increased over time)

Analyzing Heap (Generation: all)
-------------------------------

allocated by memory (22439036) (in bytes)
==============================
  14173604  /vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.4/lib/msgpack.rb:34
   3439904  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:102
   1050874  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/interruptible_sleep.rb:5
   1050544  eval:1
    324474  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:394
    286240  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/conversions.rb:139
    272648  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/finder.rb:72
    257500  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/client/active_model/apns/notification.rb:27
    195080  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:94
    193324  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/json/encoding.rb:87
    128040  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:95
    106400  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:14
    105072  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:32
     95400  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:28
     79680  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:18
     75632  /vendor/bundle/ruby/2.4.0/gems/statsd-ruby-1.4.0/lib/statsd.rb:488
     63744  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/app_runner.rb:123
     63680  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:11
     61632  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/store/redis.rb:31
     53658  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:31
     47424  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:172
     42248  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/array/grouping.rb:39
     40128  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/time/calculations.rb:230
     37008  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:13
     32280  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/hash_with_indifferent_access.rb:97
     28080  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:12
     26560  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/dispatcher/apns_http2.rb:25
     21408  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:232
      8928  /lib/ruby/2.4.0/openssl/buffering.rb:325
      7561  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274
      5320  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:180
      5184  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/connection.rb:667
      2400  /lib/ruby/2.4.0/net/http/header.rb:82
      2226  /lib/ruby/2.4.0/net/http/response.rb:62
      1760  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:7
      1452  /lib/ruby/2.4.0/logger.rb:695
      1440  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:57
      1440  /vendor/bundle/ruby/2.4.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb:8
      1440  /lib/ruby/2.4.0/net/http/header.rb:14
      1413  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/module/delegation.rb:214
      1378  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:157
      1250  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:45
      1226  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:3
      1200  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:30
      1154  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:37
      1128  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/column.rb:55
      1128  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:242
      1106  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:133
      1106  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:107
      1080  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:35

object count (106492)
==============================
  59801  /vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.4/lib/msgpack.rb:34
   7156  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/conversions.rb:139
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:102
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:94
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/finder.rb:72
   2663  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:394
   2574  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/json/encoding.rb:87
   2453  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/client/active_model/apns/notification.rb:27
   2385  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:32
   2385  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:95
   2385  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:28
   1328  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:18
    807  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/hash_with_indifferent_access.rb:97
    665  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:14
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/dispatcher/apns_http2.rb:25
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/app_runner.rb:123
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:11
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:12
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:13
    664  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/array/grouping.rb:39
    642  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/store/redis.rb:31
    418  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/time/calculations.rb:230
    326  /vendor/bundle/ruby/2.4.0/gems/statsd-ruby-1.4.0/lib/statsd.rb:488
    306  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:31
    247  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:172
    223  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:232
    133  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:180
    123  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274
     60  /lib/ruby/2.4.0/net/http/header.rb:82
     54  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/connection.rb:667
     42  /lib/ruby/2.4.0/net/http/response.rb:62
     36  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:57
     27  /lib/ruby/2.4.0/openssl/buffering.rb:325
     21  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/interruptible_sleep.rb:5
     20  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:30
     18  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:35
     17  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/schema_cache.rb:90
     15  eval:1
     14  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:439
     14  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/module/delegation.rb:214
     11  /vendor/bundle/ruby/2.4.0/gems/arel-6.0.4/lib/arel/visitors/visitor.rb:16
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:732
     10  /vendor/bundle/ruby/2.4.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb:16
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:242
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/column.rb:55
      9  /lib/ruby/2.4.0/net/http/response.rb:43
      9  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:72
      9  /lib/ruby/2.4.0/openssl/buffering.rb:182
      8  /vendor/bundle/ruby/2.4.0/gems/tesla_logging-0.1.31/lib/tesla_logging/logger_base.rb:87
      8  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:47

High Ref Counts
==============================

  127357  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:102
  81659  /vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.4/lib/msgpack.rb:34
   7548  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/finder.rb:72
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:94
   3329  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:18
   3320  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/app_runner.rb:123
   2788  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274
   2453  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/array/grouping.rb:39
   2205  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:11
   2045  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:95
   1992  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/dispatcher/apns_http2.rb:25
   1029  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:172
    514  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:13
    297  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:31
    278  /lib/ruby/2.4.0/openssl/buffering.rb:325
    266  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:180
     70  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:30
     68  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:7
     63  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:35
     61  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/interruptible_sleep.rb:5
     60  /lib/ruby/2.4.0/net/http/header.rb:14
     56  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:439
     45  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:242
     45  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/column.rb:55
     40  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:732
     32  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/module/delegation.rb:214
     30  /lib/ruby/2.4.0/net/http/header.rb:82
     26  eval:1
     24  /vendor/bundle/ruby/2.4.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb:8
     23  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/attributes.rb:98
     23  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:32
     21  /lib/ruby/2.4.0/openssl/buffering.rb:182
     21  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:45
     20  /vendor/bundle/ruby/2.4.0/gems/arel-6.0.4/lib/arel/visitors/visitor.rb:15
     20  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:12
     17  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/schema_cache.rb:13
     15  /lib/ruby/2.4.0/net/http.rb:940
     15  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:20
     15  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:3
     15  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:157
     15  /lib/ruby/2.4.0/net/http/response.rb:30
     13  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/attribute_decorators.rb:28
     12  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/core.rb:238
     12  /lib/ruby/2.4.0/net/http/response.rb:62
     11  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:37
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:171
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:472
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:107
     10  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/per_thread_registry.rb:50
      9  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/scoping/named.rb:33

Support of Rails 5.2

Hello,
I've updated my rails app and faced with issue:

[1] pry(main)> s = Session.new
=> #<Session:0x0000000a83eb68
 @attributes=
  {"id"=>nil,
   "user_id"=>nil,
   "user_roles"=>nil,
   "account_id"=>nil,
   "application_id"=>nil,
   "nonce"=>nil,
   "ts"=>nil,
   "token"=>nil,
   "updated_at"=>nil,
   "created_at"=>nil,
   "need_to_greet"=>false,
   "nonce_ts_hash"=>nil},
 @changed_attributes=nil>
[2] pry(main)> s.user_id = 111
NoMethodError: undefined method `changed?' for nil:NilClass
from /home/alex/.rvm/gems/ruby-2.3.3/gems/activemodel-5.2.0/lib/active_model/attribute_mutation_tracker.rb:45:in `changed?'
[3] pry(main)> 

###########################################
    42: def changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
    43:   attr_name = attr_name.to_s
    44:   binding.pry
    45:   forced_changes.include?(attr_name) ||
    46:     attributes[attr_name].changed? &&
    47:     (OPTION_NOT_GIVEN == from || attributes[attr_name].original_value == from) &&
 => 48:     (OPTION_NOT_GIVEN == to || attributes[attr_name].value == to)
    49: end

[1] pry(#<ActiveModel::AttributeMutationTracker>)> attr_name
=> "user_id"
[2] pry(#<ActiveModel::AttributeMutationTracker>)> attributes[attr_name].inspect
=> "nil"
###########################################
And same for my User model which uses ActiveRecord:

    42: def changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
    43:   attr_name = attr_name.to_s
    44:   binding.pry
    45:   forced_changes.include?(attr_name) ||
    46:     attributes[attr_name].changed? &&
    47:     (OPTION_NOT_GIVEN == from || attributes[attr_name].original_value == from) &&
 => 48:     (OPTION_NOT_GIVEN == to || attributes[attr_name].value == to)
    49: end

[1] pry(#<ActiveModel::AttributeMutationTracker>)> attr_name
=> "id"
[2] pry(#<ActiveModel::AttributeMutationTracker>)> attributes[attr_name]
=> #<ActiveModel::Attribute::FromDatabase:0x0000000849dc18
 @name="id",
 @original_attribute=nil,
 @type=#<ActiveModel::Type::Integer:0x00000008b6b158 @limit=4, @precision=nil, @range=-2147483648...2147483648, @scale=nil>,
 @value=nil,
 @value_before_type_cast=nil>
[3] pry(#<ActiveModel::AttributeMutationTracker>)> 

Do you have plans to support Rails 5.2? And when can we expect a new release?
Thanks :)

Spec errors in new optimizations

The new optimizations look great, thanks!

I ran into a few errors from a fresh clone of the new code. Just in case you're not already aware of these:

  1) Modis::Attribute :timestamp type is coerced
     Failure/Error: expect(found.created_at.to_s).to eq(str_time)

       expected: "2014-12-11 17:31:50 -0200"
            got: "2014-12-11 11:31:50 -0800"

       (compared using ==)
     # ./spec/attribute_spec.rb:102:in `block (3 levels) in <top (required)>'

  2) Modis::Attribute :hash type is coerced
     Failure/Error: expect(found.hash).to eq(foo: :bar)

       expected: {:foo=>:bar}
            got: {"foo"=>"bar"}

       (compared using ==)

       Diff:
       @@ -1,2 +1,2 @@
       -:foo => :bar,
       +"foo" => "bar",
     # ./spec/attribute_spec.rb:149:in `block (3 levels) in <top (required)>'

  3) Modis::Attribute variable type is coerced
     Failure/Error: expect(found.string_or_hash).to eq(foo: :bar)

       expected: {:foo=>:bar}
            got: {"foo"=>"bar"}

       (compared using ==)

       Diff:
       @@ -1,2 +1,2 @@
       -:foo => :bar,
       +"foo" => "bar",
     # ./spec/attribute_spec.rb:162:in `block (3 levels) in <top (required)>'

Release 4.3.0 breaks the Rpush initialization

rel #49

image

We can no longer initialize rpush in the old way

  # Options passed to Redis.new
  # config.redis_options = {}

The following initialization example (old way) raises a NoMethodError

config.redis_options = { url: Rails.application.config.redis_urls[:default_db] }

because it's expecting the :default key, this way

config.redis_options[:default] = { url: Rails.application.config.redis_urls[:default_db] }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.