This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module DataMapper | |
| class Property | |
| class YNBoolean < Boolean | |
| primitive ::String # otherwise adapters won't be able to correctly store the value | |
| def length | |
| @length ||= 1 | |
| end | |
| def valid?(value, negated = false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby -Ku | |
| # encoding: utf-8 | |
| require 'fileutils' | |
| require 'pathname' | |
| require 'addressable/uri' | |
| require 'ruby-github' # TODO: replace ruby-github with something better maintained |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :name, String | |
| property :age, Integer | |
| property :created_at, DateTime | |
| end | |
| class User |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/dm-core.rb b/lib/dm-core.rb | |
| index f494604..982402c 100644 | |
| --- a/lib/dm-core.rb | |
| +++ b/lib/dm-core.rb | |
| @@ -69,15 +69,6 @@ require 'dm-core/support/lazy_array' | |
| require 'dm-core/support/local_object_space' | |
| require 'dm-core/support/hook' | |
| require 'dm-core/support/subject' | |
| -require 'dm-core/model' | |
| -require 'dm-core/model/descendant_set' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is just a dummy example of a property with a "fallback" mechanism | |
| # that an adapter should use if it doesn't know how to natively persist | |
| # a property value. | |
| # | |
| # In this case we're dealing with an array that some datastores can persist | |
| # and others need to call dump before persisting and load after retrieving | |
| # a property value. | |
| module DataMapper | |
| class Property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| module A | |
| def self.included(base) | |
| base.extend ClassMethods | |
| end | |
| def a_instance_method | |
| puts 'a instance method' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Resource & EmbeddedValue: | |
| - Model::Base - descendants, append extensions/inclusions etc. | |
| - Model::Hook | |
| - Model::Property | |
| - Model::Relationship | |
| - Attributes - all the attributes related methods that can be shared between the two | |
| - PersistedState | |
| Resource: | |
| - Model::Resource (extend Model::Base) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module DataMapper | |
| class Property | |
| class JustTime < Integer | |
| primitive ::String | |
| def dump(val) | |
| case val | |
| when String | |
| h,m = val.split(':').map &:to_i | |
| h % 24 * 60 + m % 60 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/dm-types/enum.rb b/lib/dm-types/enum.rb | |
| index 68997d3..dc73415 100644 | |
| --- a/lib/dm-types/enum.rb | |
| +++ b/lib/dm-types/enum.rb | |
| @@ -1,17 +1,10 @@ | |
| require 'dm-core' | |
| +require 'dm-types/support/flags' | |
| module DataMapper | |
| class Property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| creating 20 models took: 0.760000 0.000000 0.760000 ( 0.767828) | |
| user system total real | |
| Enum: 0.390000 0.000000 0.390000 ( 0.384953) | |
| Decimal: 0.550000 0.000000 0.550000 ( 0.553226) | |
| DateTime: 0.040000 0.000000 0.040000 ( 0.040307) | |
| String: 0.070000 0.000000 0.070000 ( 0.068414) | |
| Integer: 0.040000 0.000000 0.040000 ( 0.040991) | |
| Boolean: 0.570000 0.000000 0.570000 ( 0.571986) | |
| IPAddress: 0.570000 0.000000 0.570000 ( 0.566396) | |
| Float: 0.040000 0.010000 0.050000 ( 0.045071) |