~ubuntu-branches/ubuntu/vivid/ruby-sequel/vivid

« back to all changes in this revision

Viewing changes to lib/sequel/plugins/typecast_on_load.rb

  • Committer: Package Import Robot
  • Author(s): Dmitry Borodaenko, Dmitry Borodaenko, Cédric Boutillier
  • Date: 2013-08-10 18:38:17 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20130810183817-iqanz804j32i5myi
Tags: 4.1.1-1
[ Dmitry Borodaenko ]
* New upstream release.
* Standards-Version upgraded to 3.9.4 (no changes).
* Added Build-Depend on ruby-sqlite3.

[ Cédric Boutillier ]
* debian/control: remove obsolete DM-Upload-Allowed flag.
* use canonical URI in Vcs-* fields.
* debian/copyright: use DEP5 copyright-format/1.0 official URL for Format
  field.
* Update debian/watch. Thanks Bart Martens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
    # typecast correctly (with correct being defined as how the model object
6
6
    # would typecast the same column values).
7
7
    #
8
 
    # This plugin modifies Model#set_values to call the setter methods (which typecast
 
8
    # This plugin makes model loading call the setter methods (which typecast
9
9
    # by default) for all columns given.  You can either specify the columns to
10
10
    # typecast on load in the plugin call itself, or afterwards using 
11
11
    # add_typecast_on_load_columns:
36
36
          @typecast_on_load_columns.concat(columns)
37
37
        end
38
38
 
39
 
        # Give the subclass a copy of the typecast on load columns.
40
 
        def inherited(subclass)
41
 
          super
42
 
          subclass.instance_variable_set(:@typecast_on_load_columns, typecast_on_load_columns.dup)
 
39
        # Typecast values using #load_typecast when the values are retrieved
 
40
        # from the database.
 
41
        def call(values)
 
42
          super.load_typecast
43
43
        end
 
44
 
 
45
        Plugins.inherited_instance_variables(self, :@typecast_on_load_columns=>:dup)
44
46
      end
45
47
 
46
48
      module InstanceMethods
56
58
          self
57
59
        end
58
60
 
59
 
        # Typecast values using #load_typecast when the values are retrieved from
60
 
        # the database.
61
 
        def set_values(values)
 
61
        private
 
62
 
 
63
        # Typecast values using #load_typecast when the values are refreshed manually.
 
64
        def _refresh_set_values(values)
 
65
          ret = super
 
66
          load_typecast
 
67
          ret
 
68
        end
 
69
 
 
70
        # Typecast values using #load_typecast when the values are refreshed
 
71
        # automatically after a save.
 
72
        def _save_set_values(values)
62
73
          ret = super
63
74
          load_typecast
64
75
          ret