Browse files

Fallback to REST functions... So sexy.

  • Loading branch information...
1 parent 69e8551 commit a894f81ef817ec5ad9b09c2bca20d0d23203c676 @iammerrick committed Apr 15, 2011
Showing with 26 additions and 0 deletions.
  1. +20 −0 classes/sleepy/core.php
  2. +6 −0 config/sleepy.php
View
20 classes/sleepy/core.php
@@ -11,6 +11,11 @@ class Sleepy_Core extends Model {
protected $_status = Sleepy_Core::STATE_NEW;
+ public function __construct()
+ {
+ $this->_data_url = Kohana::config('sleepy.url').$this->_data_url;
+ }
+
public function load($url = NULL)
{
$request = $this->get_request($url);
@@ -132,6 +137,21 @@ public function __isset($name)
return isset($this->_data[$name]);
}
+ public function __call($name, $arguments)
+ {
+ $request = $this->get_request($this->_data_url.$name);
+
+ if ( ! empty($arguments))
+ {
+ $request->method('POST');
+ $request->post($arguments);
+ }
+
+ $response = $request->execute();
+
+ return $response;
+ }
+
public function as_array()
{
return $this->_data;
View
6 config/sleepy.php
@@ -0,0 +1,6 @@
+<?php defined('SYSPATH') or die('No direct access allowed.');
+
+return array
+(
+ 'url' => 'Insert URL'
+);

0 comments on commit a894f81

Please sign in to comment.