Sha256: 5d96ce99f6c8075fb2981a527ec002ea510c549d7ac1edaaa86ab8d3290fe181

Contents?: true

Size: 659 Bytes

Versions: 3

Compression:

Stored size: 659 Bytes

Contents

# Makes certain AR Model methods available to the view model.
#
# Useful when the model is an AR Model.
#
# TODO Split into id delegations and AR/AC specific stuff.
#
module ViewModels
  module Extensions
    module ActiveRecord
      
      # id and param are simply delegated to the model.
      #
      # This makes it possible to use the view_model
      # for e.g. url generation:
      # * edit_user_path(view_model)
      #
      delegate :id, :to_param, :to => :model
      
      # Delegate to the action controller record identifier.
      #
      def dom_id
        ActionController::RecordIdentifier.dom_id model
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
view_models-2.0.1 lib/shared/lib/view_models/extensions/active_record.rb
view_models-2.0.0.ruby19 lib/shared/lib/view_models/extensions/active_record.rb
view_models-2.0.0 lib/shared/lib/view_models/extensions/active_record.rb