Sha256: 4629d90b2511da52b68a2a3dc64ceb3e6124f246153bb4647dcaac2e90dd6b6c

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

require "active_model"

module ElabsMatchers
  module Orm
    class Post
      extend ActiveModel::Naming
      include ActiveModel::Validations

      attr_accessor :title, :body, :signature, :category, :price, :published_on, :visible, :authors, :co_author
      validates_presence_of :title
      validates_presence_of :body
      validates_presence_of :published_on
      validates_presence_of :authors
      validates_presence_of :co_author
      validates_inclusion_of :category, :in => %w[sci-fi fantasy thriller]
      validates_inclusion_of :visible, :in => [true, false]
      validates_numericality_of :price

      class << self
        def find(id)
          new(:title => @@persisted_post.title)
        end

        def create(attributes = {})
          @@persisted_post = new(attributes)
        end
      end

      def initialize(attributes = {})
        attributes.each do |name, value|
          self.send(:"#{name}=", value)
        end
      end

      def save!
      end

      def id
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
elabs_matchers-2.0.1 spec/fixtures/post.rb
elabs_matchers-2.0.0 spec/fixtures/post.rb
elabs_matchers-1.0.1 spec/fixtures/post.rb
elabs_matchers-1.0.0 spec/fixtures/post.rb
elabs_matchers-0.0.7 spec/fixtures/post.rb
elabs_matchers-0.0.6 spec/fixtures/post.rb
elabs_matchers-0.0.5 spec/fixtures/post.rb
elabs_matchers-0.0.4 spec/fixtures/post.rb
elabs_matchers-0.0.3 lib/elabs_matchers/orm/post.rb