Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: solnic/virtus
base: v0.4.1
head fork: solnic/virtus
compare: master
This comparison is big! We’re only showing the most recent 250 commits
Commits on Sep 17, 2013
@solnic Kill mutations in Builder#initialize_primitive ca0e437
@solnic Add EmbeddedValue.handles? 26ea2a4
Commits on Sep 19, 2013
@solnic Add support for nested hash/array coercions e6edbd1
@solnic Kill mutations in Attribute::Builder, a class that I already hate, bu…
…t that's :ok:
@solnic Simplify Builder.determine_type a bit and remove dead code 4f9f82d
@solnic Simplify Extensions and kill mutations c61aeda
@solnic Fix InstanceMethod#freeze and add #set_default_attributes! 0423a1d
@solnic Set up AttributeSet up-front in ClassMethods 3bdc9be
@solnic Update reek config 2c3941b
@solnic Update flay/flog thresholds 4d44df8
@solnic Add pending test 9670bd1
@solnic README update 4789745
@solnic Merge pull request #190 from solnic/axiom-types-integration
axiom-types integration

This gigantic change brings in integration with axiom-types by replacing almost entire virtus' attribute-sublass hierarchy along with a rewritten test suite and a bunch of bug fixed.

It also changes the way you can build attribute instances by making `:name` an option instead of a required positioned argument, the new interface looks like this:

  attribute =
  attribute.type # => Axiom::Types::String
  attribute.coerce(1) # => "1"

  attribute =[String => Integer])
  attribute.type # => Axiom::Types::Hash
  attribute.coerce(:one => '1') # => {"one" => 1}

The interface to declare attribute didn't change so you still can do this:

  class User
    include Virtus
    attribute :name, String
    attribute :age, Integer
@pewniak747 pewniak747 added #set_default instance method [#154] d2e8dbd
@pewniak747 pewniak747 implement suggestions after review 8e54e66
@pewniak747 pewniak747 return self 3a83739
@solnic Fix AttributeSet#set_default
  * I broke it while resolving merge conflicts
@solnic Fix warning message for Attribute.coerce b59fe36
Commits on Sep 21, 2013
@gildo gildo * virtus.gemspec - added axiom-types as dep
Added missing dependency for 1.0.0beta
@solnic Merge pull request #192 from gildo/patch-1
* virtus.gemspec - added axiom-types as dep
@solnic Rename Named=>Accessor c15ebf5
@solnic Raise ArgumentError when :name is not valid (refs #120) 9667185
@solnic Fix alignment b756695
@solnic Introduce Virtus::Model with Core and MassAssignment 63e94b9
@solnic Introduce configuration-based extensions 39eb5a5
Commits on Sep 22, 2013
@solnic Add support for extending instances using Virtus.module builder 0428c92
@solnic Add more examples to module builder spec a061bda
@solnic Rename Virtus.{module => model} 9ccc8e3
@solnic Filter out attribute names that clash with method names (closes #120) 69cc4c4
@solnic Update README 1cac14f
@solnic Bump version ab420ac
@solnic Add Virtus.value_object module builder replacing Virtus::ValueObject …
…(now deprecated)
@solnic Deprecate including Virtus module fb9c303
@solnic Deprecate extending with Virtus module b2d4e0b
@solnic Update README 0cf747f
Commits on Sep 23, 2013
@solnic Add strict mode 4959f4b
@solnic Add support for setting :strict option via configuration e31fec8
@solnic Update README bd69f9d
Commits on Sep 24, 2013
@solnic Add Virtus.module builder 89be11d
@solnic Deprecate including Virtus in modules 5bc3f87
@solnic Add configuration support to Virtus.module 0c932a0
@solnic Update README 55ca44a
@solnic Another README update e16ce43
@solnic Remove unused dependencies 79efff4
@solnic Add support for passing option hash to module builders 3d7aa7e
@solnic Update README 9b5a8b2
@solnic Explicitly pass args to attribute definitions (refs #161) 0848af2
@solnic Bump version 0fa85aa
@solnic Remove require f97a7ab
@solnic Remove require 0f9cb89
@solnic Bump version f794d53
@solnic Allow declaring an attribute without a type (fixes #193) 013e3e0
@solnic Bump version 91748e6
@solnic Update module builder to work with type-less attribute declarations (…
…refs #193)
@solnic Bump version 1c69a1b
@craiglittle craiglittle Fix a few things in the README 49a71ad
@solnic Merge pull request #195 from craiglittle/master
Fix a few things in the README
Commits on Sep 25, 2013
@solnic Fix EmbeddedValue when new model syntax is used (fixes #196) 6463fe3
@solnic Bump version 1d33e11
@cflipse cflipse failing spec for nested coercions b7d06a5
@solnic Allow injecting coercers when using EV e42bc07
@solnic Remove commented out method eca1c74
@solnic Add Attribute#rename 3c91753
@solnic Bump version 30e16d4
@solnic Remove unneeded spec d7dfccc
Commits on Sep 26, 2013
@solnic WIP 52185eb
@solnic Minor formatting fix cc4c2bc
@solnic Merge branch 'master' into injectible-coercers-in-ev 6378f1b
@solnic Merge branch 'master' into finalizer
@solnic Add support for :required option and use it in strict mode
  * coercion doesn't raise if required is set to false and input is nil
  * raise custom error instead of ArgumentError
  * introduce Attribute#required? predicate

fixes #199
@solnic Merge branch 'master' into finalizer 999abc1
Commits on Sep 28, 2013
@solnic Mark finalize spec as pending 1edc173
@solnic Extract determining primitive into a TypeDefinition class 61d484c
@solnic Use type definition when building type instance 67489f0
@solnic Add support for :finalize option
When :finalize option is set to false attributes will not be
automatically finalized, which means their types will not be inferred.

This should be used only when there's a circular dependency issue when
one type references another type which is not yet defined.

closes #81
@solnic Update README 536e0d6
@solnic Update README 828f385
@solnic Bump version e0d2568
@solnic Rename ExtensionBuilder => Builder 3416e60
@solnic Use a block to inject attribute proc 2013eb5
@solnic Use shorter variable/method names in Builder ddb8d84
@solnic Move handling of option hash to 8964500
@solnic Refactor Builder a bit 4b23a71
@solnic Update README 048439d
@solnic Update Changelog 9b0a2e9
@solnic Smallish formatting fixes in Changelog 4f68b8b
@solnic Add compare link to Changelog ca1d9b1
Commits on Sep 30, 2013
@dkubb dkubb Fix whitespace 051e77f
@dkubb dkubb Add MIT license to gemspec
[Fix #201]
@dkubb dkubb Update license date range 70baf47
@dkubb dkubb Upgrade axiom-types gem dependency 772a338
@solnic Simplify {Collection,Hash}.merge_options! d818f14
@solnic Remove overridden
  * it used to be needed when #finalize was called automatically
@solnic Minor clean up in Attribute::Builder b65535e
@solnic Use attribute readers in Attribute::Builder 3773e71
@solnic Simplify EmbeddedValue.build_type c0f0687
@solnic Make sure finalize works with symbols too f0e322b
@solnic Update flay and flog thresholds 8d663d8
@solnic Add docs for Attribute a9011d0
Commits on Oct 01, 2013
@solnic Use copy of default options in attribute method
Otherwise options would mix together when models are inheriting from
another model

fix #202
@solnic Freeze default option hash created by builder (refs #202) c1adaf0
@solnic Add missing module/class descriptions c516a56
@solnic Update reek config 85884bd
@solnic Remove AttributeSet#set_default 17d2dc5
@solnic Update reek config d3a5920
@solnic Allow ValueObject to skip the constructor 538e013
@solnic Remove redundant method 0a5bf21
@solnic Update coverage threshold e4f79ff
@solnic Update mutant config 55baab9
Commits on Oct 02, 2013
@solnic Kill mutations in Builder::HookContext#finalize? 3e3fd62
@solnic Kill mutations in
This is a private method that is always called via
Virtus.{model,module,value_object} which always sets options to be an empty
hash by default, so no need to repeat that here.
@solnic Kill mutations in Builder#add_included_hook
  * extensions are not really needed for Virtus.model
  * with a Virtus.model we don't have to call super, there's no use case for that
@solnic Clean up Builder
  * Move more logic to the hook context to DRY things up
  * Default type = nil because it will be resolved to Object anyway
  * Move building default option hash to Configuration
  * Kill more mutations
@solnic Kill mutations in ModuleBuilder abfcca4
@solnic Add more docs 6823810
@solnic Add support for passing attribute class as the type
Allows this:[Attribute::Virtus::Boolean])

fixes #204
@solnic Bump version e4c3835
@solnic Remove reduntant code (:heart: mutant) dd72611
@solnic Remove explicit return in Extensions#values 7c62889
@solnic Simplify Extensions a bit 4550cd2
@solnic Update docs ba4132c
@solnic No need to extend an object with Constructor (:heart: mutant) 61d3bd0
@solnic No need to extend virtus model with DescendantTracker
I have no idea why it was there, honestly
Commits on Oct 03, 2013
@solnic Kill mutations in ModuleExtensions a5a7014
@solnic Remove dead code 6afcc83
@solnic Minor simplification in ValueObject.included 8963fb8
@solnic Simplify Extensions::Methods.extended 5bc6b09
@solnic Include allowed_writer_methods only when mass-assignment is turned on a385ca2
@solnic Adjust flay and flog thresholds d4c00ae
Commits on Oct 05, 2013
@solnic Add docs for Attribute::Coercible 969dcc0
@solnic Update docs for Collection 843f02f
@solnic Simplify default option in Collection cb36a87
@solnic Update docs for Hash a16bf9c
@solnic Update docs for EmbeddedValue 7f50692
@solnic Add docs for Strict extension b50d5fc
@solnic Update Changelog bae2d17
Commits on Oct 06, 2013
@solnic Update axiom-types ec761a6
@solnic Remove rbx from allowed_failures 38c4355
Commits on Oct 08, 2013
@solnic Set name in the extended hook rather than during finalization
Otherwise name won't be available for attributes in a model with
:finalize set to false
@solnic Bump version da3b45b
Commits on Oct 13, 2013
@solnic DRY up attribute & ev coercers
  * introduce a base Virtus::Coercer class
  * add test for strict mode and EV
  * refactor Attribute::Coercer to use attr readers and remove #[] method

fixes #212
@solnic Update flay threshold c028d65
Commits on Oct 16, 2013
@solnic Bump version to 1.0.0 8c8263b
@solnic Update d344e5b
Commits on Oct 26, 2013
@elskwid elskwid Add CONTRIBUTING 441f6dd
Commits on Oct 27, 2013
@solnic Fix strict mode in boolean attribute (fixes #219) d1d09ef
Commits on Oct 28, 2013
@Antti Antti Performance fix for AttributeSet#each.
Using uniq on attributes array is slow, because it must compare
attributes to each other. This change makes initialization of a new
object with Virtus attributes 3 times faster.
Commits on Nov 06, 2013
@rewritten rewritten Fixed typo in ivar assignment in CoercionError a8b1594
Commits on Nov 07, 2013
@snusnu snusnu Merge pull request #223 from rewritten/typo_on_coercion_error
Typo in ivar assignment in CoercionError
Commits on Nov 22, 2013
@senny senny re-introduce `ValueObject#with` which was removed with 6ea32ed.
This method is part of the public interface of a ValueObject.
It was removed due to lacking tests. This commit adds both the method
and tests.
Commits on Dec 03, 2013
@RKushnir RKushnir Fix typo in mass-assignment module 325d48d
@snusnu snusnu Merge pull request #228 from RKushnir/patch-1
Fix typo in mass-assignment module
Commits on Dec 10, 2013
@solnic Bump version 8b1c80c
@solnic Update Changelog 82046d6
@solnic Bump coercible f7d0c12
@solnic Update Changelog a1bee16
@solnic Update travis config 1184497
@solnic Run metrics task on travis aaec11f
@solnic Allow failures on rbx b27c265
@solnic Turn off min coverage 6e7f6df
Commits on Dec 19, 2013
@codesnik codesnik Improve value_object's #hash uniformity
Array#hash is designed to be uniform, unlike reduce(:^).hash

class Point
  include Virtus.value_object
  values do
     attribute :x, Integer
     attribute :y, Integer
end 1, y: 1).hash == # was true 1).hash == 1).hash # was true
@solnic Merge pull request #233 from codesnik/fixing_hash
Improve value_object's #hash uniformity
Commits on Jan 06, 2014
@solnic Add ruby 2.1.0 to travis config 034b2de
@solnic Update README
  * Remove obsolete examples (closes #218)
  * Remove redundant LICENSE section
@solnic Merge pull request #220 from reevoo/master
Performance fix for AttributeSet#each.
Commits on Jan 31, 2014
@amarshall amarshall Add Attribute#defined? to return if attribute value has been defined d84f4df
@amarshall amarshall Use Attribute#default? in AttributeSet#skip_default? 67ca515
@amarshall amarshall Don’t override already-defined default values when freezing
Further, make `AttributeSet#set_default_attributes!` behavior respect
its documentation, which implied its only difference from
`set_default_attributes` was that it additionally set lazy attributes,
which was not entirely true since it also set non-lazy (and lazy)
attributes that had already been defined.
@solnic Merge pull request #240 from amarshall/freezing-defaults
Don’t override already-defined default values when freezing
Commits on Feb 24, 2014
@rrrene rrrene Add docs badge to README ca5ee30
@solnic Merge pull request #249 from rrrene/patch-1
Add docs badge to README
Commits on Mar 12, 2014
@solnic Update deps 061dfd3
@solnic Bump version to 1.0.2 8f5644c
@solnic Update Changelog a0cda97
Commits on Mar 23, 2014
@chastell chastell TypeLookup: drop unused variable 32344cb
@chastell chastell TypeDefinition: side-step an ‘instance variable not initialized’ warning 9e2d2a0
@chastell chastell Options: side-step an ‘instance variable not initialized’ warning 838d363
Commits on Mar 24, 2014
@solnic Merge pull request #255 from chastell/warning_free
Make Virtus warning-free
@chastell chastell Options#define_option_method: don’t clobber `false` ivars 762db00
@solnic Merge pull request #256 from chastell/warning_free
Options#define_option_method: don’t clobber `false` ivars
Commits on Apr 03, 2014
@lfender6445 lfender6445 Fix boolean_map example in readme ab4febf
@solnic Merge pull request #259 from lfender6445/fix_boolean_map_example
Fix boolean_map example in readme
Commits on Apr 15, 2014
@ntl ntl Expose the name of the attribute failing coercion
Resolves #254

Currently, when you `include Virtus.model(strict: true)`, and you fail
to supply any of the attributes, the exception message doesn't let you
know *which* attribute was missing. This can lead to painful debugging
sessions, particularly when a model embeds other models.

This pull request attempts to address that by providing visibility into
the name of the attribute that could not be coerced. Since not all
`Virtus::Attribute` instances actually *have* a name, we fall back to
the old message when one isn't present.
Commits on Apr 16, 2014
@solnic Merge pull request #263 from ntl/expose_attribute_from_coercion_error
Expose the name of the attribute failing coercion
Commits on Apr 17, 2014
@postmodern postmodern Allow Configuration#initialize to initialize the ivars. 994d785
@postmodern postmodern Remove Configuration#call. b44c7d2
@postmodern postmodern Removed in favor of Configuration#initialize.
* yielding the object from within #initialize and having .new return the
  value is essentially what was doing.
@solnic Merge pull request #265 from postmodern/simplify
@hampei hampei Made Range attributes not be treated as a Collection to avoid crashes a72850b
Commits on May 16, 2014
@loganhasson loganhasson Update specs to RSpec 2.14.8
This conversion is done by Transpec 1.13.1 with the following command:
    transpec --keep its

* 78 conversions
    from: obj.should
      to: expect(obj).to

* 35 conversions
    from: == expected
      to: eq(expected)

* 8 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 2 conversions
    from: it { should have(n).keys }
      to: it 'has n keys' do expect(subject.keys.size).to eq(n) end
Commits on May 19, 2014
@fnando fnando Set InstanceMethods#to_h as an alias. 9e83fd5
@solnic Merge pull request #269 from fnando/to_h-alias-pointing-to-attributes
Set InstanceMethods#to_h as an alias.
Commits on Jun 04, 2014
@rrrene rrrene Update docs badge in README
Update the URL of the docs badge to include it from instead of (the former being the successor of the Inch Pages project).
Commits on Jul 04, 2014
@edgibbs edgibbs Add handling of nil values for collection attributes 9a2a389
Commits on Jul 11, 2014
@trptcolin trptcolin Allow mixing in multiple Virtus.modules
Known caveat: if one module wants constructors/coercions/mass-assignment
but the other one doesn't, the one that *does* want those features will
win since it mixes in the module.

fixes #260
fixes #274
@solnic Merge pull request #276 from trptcolin/multiple_modules
Allow mixing in multiple Virtus.modules

fixes #260
fixes #274
Commits on Jul 14, 2014
@trptcolin trptcolin Handle multiple modules mixed into another module
refs #260
Commits on Jul 17, 2014
@hendricius hendricius add readme for overriding setters 54db3ce
@solnic Merge pull request #279 from hendricius/master
add readme for overriding setters
Commits on Jul 24, 2014
@solnic Merge pull request #268 from loganhasson/master
Update specs to RSpec 2.14.8 (Updated)
@solnic Use ruby 2.1 in dev mode 9d32542
@solnic [WIP] bump devtools and rspec 568c4d1
@solnic Fix specs after upgrading to rspec 3.0.0 3acefac
@solnic Merge pull request #272 from rrrene/patch-2
Update docs badge in README
@solnic Merge pull request #277 from trptcolin/more_module_nesting
Handle multiple modules mixed into another module
@solnic Merge pull request #275 from edgibbs/handle_nil_for_collections
Add handling of nil values for collection attributes
@solnic Fix spec and avoid double-coercion in Collection#coerce 84f8d96
@solnic Update Changelog 165db2e
@solnic Bump version to 1.0.3 d369a18
@solnic Update travis config 782e6b8
@solnic Add inflecto gem needed in test mode 97f9262
@solnic Merge pull request #261 from hampei/fix_range_attributes
Fixed attributes with Range type
@solnic Add a test for Range attribute type 7131561
@solnic Updat Changelog e8edbf8
@solnic Update deps 996d34f
@solnic Add a list of supported rubies to README
closes #229
@solnic Fix Json example in the README (closes #245) a325a23
@solnic Add a note about Boolean type (closes #234) d238b7e
@solnic Set strict type for member/key/value types too
fixes #280
@solnic Update changelog 1def974
Commits on Jul 25, 2014
@solnic Fix date in the changelog 51312f5
Commits on Aug 10, 2014
@solnic Update 5093278
Commits on Jan 03, 2015
@solnic Support :required option in a configured module
Makes it possible to set :required flag on a virtus module:

mod = Virtus.model(required: false)
klass = { include mod; attribute :name }
klass.attribute_set[:name].required? # => false
@solnic Update Changelog a20a264
@solnic Add info about default values on dynamically extended objects (closes #… ead555b
@solnic Update travis config d4c597d
@solnic Update devel deps c9285bc
@solnic Bump version 0bf51d3
@solnic Remove simple-cov portion of spec_helper 5c842ef
@solnic Convert specs with transpec
closes #300
@solnic Pull test gems out of test group 38399b6
@solnic Update BADGES
ci skip
@solnic Update README
ci skip

@solnic Enable CC coverage addb324
@solnic Fix gem badge [ci skip] 5763a5d
@solnic Update changelog [ci skip] 54ee3ee
Commits on Jan 04, 2015
@solnic Update 310e67a
Commits on Jan 07, 2015
@blashca blashca Fix @solnic's age 1189533
@blashca blashca Make solnic's age correct as of today e648e2f
@solnic Merge pull request #306 from blashca/master
Fix @solnic's age
Commits on Mar 10, 2015
@lucasmazza lucasmazza Add The `nullify_blank` option to nullify empty Strings when coercion…
… fails.

This module aims to make Virtus be a bit more compatible with web forms where all
the input are Strings and empty attributes are represented as empty Strings.
Commits on Mar 17, 2015
@solnic Merge pull request #314 from lucasmazza/nullify_blank
Add The `nullify_blank` option to nullify empty Strings when coercion fails
Commits on Mar 18, 2015
@solnic Bump version [ci skip] 3e98f42
@solnic Update Changelog [ci skip] 2a5bc32
Commits on Apr 02, 2015
@jdongelmans jdongelmans Fix a small typo in documentation
The demo error-message was not right and has been altered.
@solnic Merge pull request #317 from jdongelmans/fix-attribute-documentation-…

Fix a small typo in documentation
Commits on Apr 16, 2015
@solnic Update d494b95
Commits on Jul 04, 2015
@novikserg novikserg Revert "Include allowed_writer_methods only when mass-assignment is t…
…urned on"

This reverts commit a385ca2.
@novikserg novikserg Add tests for "attributes" attribute 00b9d85
Commits on Jul 15, 2015
@solnic Merge pull request #326 from novikserg/325_mass_assignment_bug_fix
mass assignment bug fix

fixes #325