lib/tito/event.rb in tito-0.1.11 vs lib/tito/event.rb in tito-0.2.0

- old
+ new

@@ -1,40 +1,65 @@ module Tito - class Event < Base - belongs_to :account + class Event < Base - property :title, type: :string - property :security_token, type: :string + def path + "#{account_slug}/#{slug}" + end - def account_id - attributes['account_id'] || attributes['account-id'] + def put_path + path end - def account_id=(val) - attributes['account_id'] = val + def post_path + "#{account_slug}/events" end - def security_token - attributes['security_token'] || attributes['security-token'] + def self.for_account(url) + RequestProxy.new(proxy_class: self, proxy_path: url) end - class << self + def self.[](url) + self.for_account(url) + end - def get(path) - parts = path.split('/') - where(account_id: parts[0]).find(parts[1]).first - end + # property :title, type: :string + # property :slug, type: :string + # property :account_slug, type: :string + # property :security_token, type: :string - def path(params=nil) - prefix_path = '%{account_id}' - path_params = params.delete(:path) || params - parts = [].unshift(prefix_path % path_params.symbolize_keys) - if !params[:id] - parts << 'events' - end - File.join(*parts) - rescue KeyError - raise ArgumentError, "Please make sure to include account_id" - end - end + # def account_id + # attributes['account_id'] || attributes['account-id'] + # end + + # def account_id=(val) + # attributes['account_id'] = val + # end + + # def security_token + # attributes['security_token'] || attributes['security-token'] + # end + + # def account_slug + # attributes['account_slug'] || attributes['account-slug'] + # end + + # class << self + + # def get(path) + # parts = path.split('/') + # where(account_id: parts[0]).find(parts[1]).first + # end + + # def path(params=nil) + # prefix_path = '%{account_id}' + # path_params = params.delete(:path) || params + # parts = [].unshift(prefix_path % path_params.symbolize_keys) + # if !params[:id] + # parts << 'events' + # end + # File.join(*parts) + # rescue KeyError + # raise ArgumentError, "Please make sure to include account_id" + # end + # end end end \ No newline at end of file