lib/hara.rb in hara-0.2.2 vs lib/hara.rb in hara-0.3.0
- old
+ new
@@ -1,2 +1,40 @@
-require 'hara/base'
-require 'hara/main'
+require "hara/version"
+
+module Hara
+ class << self
+ #decode message, return action and args
+ def decode_msg msg
+ msg = JSON.parse(msg)
+ msg.values_at 'action', 'args'
+ end
+
+ def encode_msg action, *args
+ {action: action, args: args}.to_json
+ end
+
+ def filter_class
+ @filter_class || DefaultFilter
+ end
+
+ def filter_class= klass
+ @filter_class = klass
+ end
+
+ def filter_pool_size= size
+ @filter_pool_size = size
+ end
+
+ def filter_pool_size
+ @filter_pool_size || 10
+ end
+
+ def filter_pool
+ @filter_pool ||= filter_class.pool(size: filter_pool_size)
+ end
+ end
+end
+
+require 'hara/app'
+require 'hara/filter'
+require 'hara/default_filter'
+require 'hara/server'