[Groonga-commit] droonga/droonga-engine at 9bfb94d [master] Define class to manage node's role

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Apr 21 11:35:06 JST 2015


YUKI Hiroshi	2015-04-21 11:35:06 +0900 (Tue, 21 Apr 2015)

  New Revision: 9bfb94deaf27b7ccb4c8a34383e9c4ba59e7dcf9
  https://github.com/droonga/droonga-engine/commit/9bfb94deaf27b7ccb4c8a34383e9c4ba59e7dcf9

  Message:
    Define class to manage node's role

  Added files:
    lib/droonga/node_role.rb

  Added: lib/droonga/node_role.rb (+50 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/node_role.rb    2015-04-21 11:35:06 +0900 (b989d71)
@@ -0,0 +1,50 @@
+# Copyright (C) 2015 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+require "droonga/serf"
+
+module Droonga
+  class NodeRole
+    SERVICE_PROVIDER   = "service-provider"
+    ABSORB_SOURCE      = "absorb-source"
+    ABSORB_DESTINATION = "absorb-destination"
+
+    ROLES = [
+      SERVICE_PROVIDER,
+      ABSORB_SOURCE,
+      ABSORB_DESTINATION,
+    ]
+
+    class << self
+      def valid?(role)
+        ROLES.include?(role)
+      end
+    end
+
+    def initialize(role)
+      @role = normalize(role)
+    end
+
+    def to_s
+      @role
+    end
+
+    private
+    def normalize(role)
+      role = Role::SERVICE_PROVIDER unless self.class.valid?(role)
+      role
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index