Sha256: 6904f3ed895fca686fda68785fe12cb75176f18243fbb971fce5781a11512881

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

require 'active_model'

module Reviewed
  class Base
    include ::Reviewed::Embeddable

    extend ::ActiveModel::Naming

    attr_accessor :attributes

    def initialize(data)
      self.attributes = objectify(data)
    end

    class << self

      def path
        @resource_name ||= association_name
      end

      def association_name
        self.name.demodulize.downcase.pluralize
      end
    end

    def respond_to?(sym, include_private=false)
      return true if super
      @attributes.has_key?(sym)
    end

    def method_missing(sym, *args, &block)
      if @attributes.has_key?(sym)
        @attributes[sym]
      else
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reviewed-0.1.28 lib/reviewed/base.rb