salesking / sk_sdk

SalesKing SDK for creating apps and using the API
https://www.salesking.eu
MIT License
8 stars 2 forks source link

Make setup easier by having a base class #4

Closed grosser closed 13 years ago

grosser commented 13 years ago

Setup is simpler and can be done by hand(no make needed) + users can monky-patch Base to add additional methods

class SK::SDK::Base < ActiveResource::Base
  extend SK::SDK::ClassMethods
  include SK::SDK::InstanceMethods
  self.format = :json
end

# only needed once
SK::SDK::Base.set_connection(
...
)

# simple object creating
class Client < SK::SDK::Base;end

# create objects in King namespace
%w[Client Invoice Product LineItem].each do |model|
  eval "class King::#{model} < SK::SDK::Base;end"
end
schorsch commented 13 years ago

Good point, will take it into account

schorsch commented 13 years ago

implemented in v0.0.6 thanks for your input