Sha256: 609d2614ba29ee27b2014aa32f3fad407a4408f654542d9070e5c83d6ca34955

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 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 initialize(data)
      self.attributes = objectify(data)
    end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reviewed-0.1.27 lib/reviewed/base.rb
reviewed-0.1.26 lib/reviewed/base.rb
reviewed-0.1.25 lib/reviewed/base.rb
reviewed-0.1.24 lib/reviewed/base.rb
reviewed-0.1.23 lib/reviewed/base.rb
reviewed-0.1.22 lib/reviewed/base.rb
reviewed-0.1.21 lib/reviewed/base.rb