Sha256: 1f99210217751ee525ebd3b4c83ddb182971fd7ca5b76d831ae0cd6b7907d9bc

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

Dir["#{File.dirname(__FILE__)}/post/*"].each { |c| require c unless File.directory?(c) }

module Ubiquitously
  module Service
    class Post < Ubiquitously::Base
      include Ubiquitously::Ownable::Post
      include Ubiquitously::Postable::Post
      include Ubiquitously::Restful::Post
      include Ubiquitously::Loggable::Post
      
      #validates_presence_of :title, :description, :tags
      attr_accessor :token
      attr_accessor :title, :url, :description, :tags, :categories, :remote, :service_id
      # some sites check to see if you're posting duplicate content!
      # perhaps "vote" can mean "favorite" also
      attr_accessor :image, :rating, :privacy, :vote, :status, :must_be_unique, :captcha
      attr_accessor :service_url, :user, :upvotes, :downvotes
      # the application that automates! ("Posted by TweetMeme")
      attr_accessor :source, :source_url
      # kind == regular, link, quote, photo, conversation, video, audio, answer
      attr_accessor :kind
      # plain, html, markdown
      attr_accessor :format, :extension
      # max 55 chars, for custom url if possible
      attr_accessor :slug
      # published, draft, submission, queue
      attr_accessor :state
      
      before_create { self.token = tokenize }
      before_update { self.token = tokenize }
      after_create { self.token = nil }
      after_update { self.token = nil }
      
      def initialize(attributes = {})
        apply attributes
        
        raise 'please give me a user' if self.user.blank?
        
        self.format ||= "text"
        self.privacy = 0 if self.privacy.nil?
        self.categories ||= []
        self.tags ||= []
        self.upvotes ||= 0
        self.downvotes ||= 0
        
        # for httparty
        @auth = {:username => username, :password => password}
      end
      
      def remote
        @remote ||= self.class.find(:url => self.url, :user => self.user)
      end
      
      def access_token
        user.account_for(self).access_token
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ubiquitously-0.1.0 lib/ubiquitously/models/service/post.rb