Sha256: f2dd07c1fa7c5e539f10e9285aecce6ba7f3c7e1a67eee1a3a0ea2248fa34d1d

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

module Restorm
  module Model
    # This module includes basic functionnality to Restorm::Model
    module Base
      extend ActiveSupport::Concern

      # Returns true if attribute_name is
      # * in resource attributes
      # * an association
      #
      # @private
      def has_key?(attribute_name)
        has_attribute?(attribute_name) ||
          has_association?(attribute_name)
      end

      # Returns
      # * the value of the attribute_name attribute if it's in orm data
      # * the resource/collection corrsponding to attribute_name if it's an association
      #
      # @private
      def [](attribute_name)
        get_attribute(attribute_name) ||
          get_association(attribute_name)
      end

      # @private
      def singularized_resource_name
        self.class.name.split('::').last.tableize.singularize
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restorm-1.0.0 lib/restorm/model/base.rb