{"id":260764,"date":"2015-07-06T12:40:04","date_gmt":"2015-07-06T08:40:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=260764"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=260764","title":{"rendered":"\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 Ruby"},"content":{"rendered":"<p>     \t\u0414\u0437\u0435\u043d Ruby \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u0437\u0434\u0435\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043b\u0438\u0448\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u043e\u043b\u0435\u0435 \u00ab\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u00bb. \u041f\u043e\u0447\u0442\u0438 \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u044f \u0447\u0438\u0442\u0430\u043b \u043f\u0440\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043c\u043d\u0435 \u0436\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043c\u043d\u0435 \u00ab\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u00bb \u043d\u0430 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c, \u043f\u043b\u043e\u0445\u043e \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435. <br \/>  \u0418\u0442\u0430\u043a, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u0418\u0437 \u0434\u0430\u043b\u0435\u043a\u0430\u2026 \u041f\u0440\u043e Ruby \u0438 Enum&#8217;\u044b<\/b><br \/>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0412\u0430\u0441 \u043f\u043e\u0441\u0430\u0434\u0438\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0412\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u0447\u0443\u0436\u043e\u0439 \u043a\u043e\u0434. \u0412\u0438\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0443:   <\/p>\n<pre><code class=\"ruby\"> LogRec.create(uid: task[:tid], lrtype: 'tsk', rc_time: rc_time, start: task[:start] )<\/code><\/pre>\n<p>  \u0427\u0438\u0442\u0430\u0435\u0442\u0435 \u043a\u043e\u0434 \u0434\u0430\u043b\u044c\u0448\u0435:   <\/p>\n<pre><code class=\"ruby\"> LogRec.create(uid: task[:tid], lrtype: 'task', rc_time: rc_time, start: task[:start] )<\/code><\/pre>\n<p>  \u0421\u0442\u0440\u0430\u043d\u043d\u043e, \u0442\u0430\u043c &#8216;tks&#8217;, \u0442\u0443\u0442 &#8216;task&#8217;. \u041e\u043a, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0432 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 (\u0435\u0449\u0435 \u043a\u0443\u0434\u0430 \u2014 \u043d\u0438\u0431\u0443\u0434\u044c), \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438. \u0427\u0438\u0442\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435, \u043e\u043f\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0430\u2026<br \/>  \u0412\u044b\u0432\u043e\u0434: \u0412\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u043a\u0443\u0434\u0430 \u2014 \u0442\u043e, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0443\u0447\u0448\u0435 \u0432c\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Enum&#8217;\u044b. \u0412 Ruby Enum \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:   <\/p>\n<pre><code class=\"ruby\">module ProtocolElementTypeName   TASK  = 'task'   NOTE  = 'note'   EVENT = 'event' end<\/code><\/pre>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0432\u043e \u0432\u0441\u0435\u0445 \u0412\u0430\u0448\u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445 \u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430(ProtocolElementTypeName::TASK) \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u043f\u0435\u0447\u0430\u0442\u043e\u043a!<\/p>\n<p>  <b>\u041f\u043e\u0447\u0442\u0438 \u00ab\u0424\u0430\u0431\u0440\u0438\u043a\u0430\u00bb<\/b><br \/>  \u0427\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u0434 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0432\u0438\u0434\u0438\u043c:  <\/p>\n<pre><code class=\"ruby\">log = Array.new       log_recs.each do |log_rec|         case log_rec.lrtype           when 'qc'             log.push({uid: log_rec.uid, type: log_rec.lrtype, parid: log_rec.parid, start: log_rec.start.gsub(&quot; &quot;, &quot;T&quot;), ts: log_rec.ts.gsub(&quot; &quot;, &quot;T&quot;), rc_time: log_rec.rc_time.gsub(&quot; &quot;, &quot;T&quot;), state: log_rec.state, rcpt: log_rec.recipient})           when 'tstate', 'etsks'             log.push({type: log_rec.lrtype, parid: log_rec.parid, start: log_rec.start.gsub(&quot; &quot;, &quot;T&quot;), end: log_rec.end, ts: log_rec.ts.gsub(&quot; &quot;, &quot;T&quot;), rc_time: log_rec.rc_time.gsub(&quot; &quot;, &quot;T&quot;), state: log_rec.state, rcpt: log_rec.recipient})           when 'pcb', 'grps'             log.push({type: log_rec.lrtype, ts: log_rec.ts.gsub(&quot; &quot;, &quot;T&quot;), rc_time: log_rec.rc_time.gsub(&quot; &quot;, &quot;T&quot;), rcpt: log_rec.recipient})           when 'egrp', 'tgrp'             log.push({type: log_rec.lrtype, parid: log_rec.parid, ts: log_rec.ts.gsub(&quot; &quot;, &quot;T&quot;), rc_time: log_rec.rc_time.gsub(&quot; &quot;, &quot;T&quot;), state: log_rec.state, rcpt: log_rec.recipient})           when 'rprefs'             log.push({type: log_rec.lrtype, parid: log_rec.parid, ts: log_rec.ts.gsub(&quot; &quot;, &quot;T&quot;), rc_time: log_rec.rc_time.gsub(&quot; &quot;, &quot;T&quot;), rcpt: log_rec.recipient})           else             log.push({uid: log_rec.uid, type: log_rec.lrtype, parid: log_rec.parid, start: log_rec.start.gsub(&quot; &quot;, &quot;T&quot;), end: log_rec.end, ts: log_rec.ts.gsub(&quot; &quot;, &quot;T&quot;), rc_time: log_rec.rc_time.gsub(&quot; &quot;, &quot;T&quot;), state: log_rec.state, rcpt: log_rec.recipient})         end <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0448\u0435\u0442 \u043d\u0430 \u041e\u041e \u044f\u0437\u044b\u043a\u0435, \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0442\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u2014 \u043e\u0447\u0435\u043d\u044c \u0433\u0440\u0443\u0441\u0442\u043d\u043e. \u0415\u0441\u043b\u0438 \u0412\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0435\u0440\u0435\u0434\u0443 if-\u043e\u0432 \u0438\u043b\u0438 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 switch, \u043d\u0430\u0434\u043e \u043a\u0440\u0438\u0447\u0430\u0442\u044c: \u00ab\u041f\u043e\u043c\u043e\u0433\u0438\u0442\u0435! \u0425\u0443\u043b\u0438\u0433\u0430\u043d\u044b \u0437\u0440\u0435\u043d\u0438\u044f \u043b\u0438\u0448\u0430\u044e\u0442!!!\u00bb<br \/>  \u041a\u0430\u043a \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443? \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u00ab\u0424\u0430\u0431\u0440\u0438\u043a\u0430\u00bb. \u0421\u043c\u044b\u0441\u043b \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0438\u0437 \u043a\u043e\u0434\u0430: \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u00ab\u0443\u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f\u00bb \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u0422\u0438\u043f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u043e\u043b\u0435 lrtype. <br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044c, \u0433\u0434\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f lrtype:   <\/p>\n<pre><code class=\"ruby\">module LogRecObjType # \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f obj_type \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435  LogRec   EVENT         = 'event'   QC               = 'qv'   TASK           = 'task' end<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c, \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c Hash, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e lrtype \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430:   <\/p>\n<pre><code class=\"ruby\"> @@types_objects = {       ObjectJournal::QC      =&gt; :complect_qc,       ObjectJournal::EVENT =&gt; :complect_event,       ObjectJournal::TASK =&gt; :complect_task   }<\/code><\/pre>\n<p>  \u0418 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0443\u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430:  <\/p>\n<pre><code class=\"ruby\">def complect_qc     obj = {         uid: self.id,         type: self.lrtype,         parid: self.parid,         start: self.start,         ts: self.ts,         rc_time: self.rc_time,         state: self.state,         rcpt: self.recipient     }     return obj   end # \u0418 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435...<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e lrtype.   <\/p>\n<pre><code class=\"ruby\"> def complect_object_journal      if @@types_objects.has_key?(self.lrtype)        return send(@@types_objects[self.lrtype])      else        return complect_another      end   end<\/code><\/pre>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438 \u2014 \u0432\u0441\u0435! \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0442\u043e\u0442 \u0443\u0436\u0430\u0441\u043d\u044b\u0439 switch:   <\/p>\n<pre><code class=\"ruby\">log = log_recs.map { |x| x.complect_object_journal }<\/code><\/pre>\n<p>  <b>\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434<\/b><br \/>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e: \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 Operation, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 \u2014 Goal \u0438 Task. \u0412\u0441\u0435 \u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u0438\u0439 \u0441\u0445\u043e\u0436\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442:   <\/p>\n<pre><code class=\"ruby\"> class Operation     def return_operation       operation = {           :goal =&gt; {:id =&gt; goal.gid, :title  =&gt; goal.title, :ts =&gt; goal.ts},           :task =&gt; {:is_problem =&gt; task.is_problem, :state =&gt; task.state,:author =&gt; task.author_id}       }       return operation     end   end    class Event &lt; Operation    def return_operation       operation = {           :goal =&gt;  {:id =&gt; goal.gid, :title      =&gt; goal.title, :ts =&gt; goal.ts,  :author  =&gt; goal..author_id, :holder  =&gt; complect_goal_content_header},           :task =&gt; {:is_problem =&gt; task.is_problem, :state =&gt; task.state,:author     =&gt; task.author_id}       }       return operation     end  end  class Task &lt; Operation     def return_operation       operation = {           :goal =&gt; {:id =&gt; goal.gid, :title  =&gt; goal.title, :ts =&gt; goal.ts},           :task =&gt;  {:id  =&gt; task.gid, :title =&gt; task.title,  ts  =&gt; task.ts, :author  =&gt; task..author_id, :holder =&gt; complect_holder}       }       }       return operation     end end<\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u0432\u0438\u0434\u0438\u043c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430(\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043b\u044e\u0447 goal \u0432 Task \u0438 Operation). \u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043c\u0435\u0442\u043e\u0434\u0430 return_operation \u00ab\u043c\u0443\u0442\u0438\u0440\u0443\u0435\u0442\u00bb \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u043d\u043e \u043a\u043b\u044e\u0447\u0438(goal \u0438 task) \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438. \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u00bb. \u0421\u043c\u044b\u0441\u043b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0448\u0430\u0433\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432 \u0446\u0435\u043b\u043e\u043c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:   <\/p>\n<pre><code class=\"ruby\">class Operation     def return_operation       operation = {           :goal =&gt; complect_goal,           :task =&gt; complect_task       }       return operation     end      def complect_goal       goal_obj = {           :id         =&gt; goal.gid,           :title      =&gt; goal.title,           :ts         =&gt; goal.ts,       }       return goal_obj     end      def complect_task       #task = self.task       task_obj = {           :is_problem =&gt;task.is_problem,           :state      =&gt; task.state,           :author    =&gt; task.author_id       }       return task_obj     end   end    class Event &lt; Operation     def complect_goal       goal_obj = {           :id         =&gt; goal.gid,           :title      =&gt; goal.title,           :ts         =&gt; goal.ts,           :author     =&gt; goal.author_id,           :holder     =&gt; complect_goal_content_header       }       return goal_obj     end   end    class Task &lt; Operation     def complect_task       task_obj = {           :id         =&gt; task.gid,           :title      =&gt; task.title,           :ts         =&gt; task.ts,           :author     =&gt; task.author_id,           :holder     =&gt;  complect_holder       }       return task_obj     end   end <\/code><\/pre>\n<p>  <b>\u0411\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c \u0438 \u043f\u043e\u0436\u0435\u043b\u0430\u043d\u0438\u044f\u043c. \u0421\u043f\u0430\u0441\u0438\u0431\u043e !<\/b>     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/261439\/\"> http:\/\/habrahabr.ru\/post\/261439\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u0414\u0437\u0435\u043d Ruby \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u0437\u0434\u0435\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043b\u0438\u0448\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u043e\u043b\u0435\u0435 \u00ab\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u00bb. \u041f\u043e\u0447\u0442\u0438 \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u044f \u0447\u0438\u0442\u0430\u043b \u043f\u0440\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043c\u043d\u0435 \u0436\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043c\u043d\u0435 \u00ab\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u00bb \u043d\u0430 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c, \u043f\u043b\u043e\u0445\u043e \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435. <br \/>  \u0418\u0442\u0430\u043a, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-260764","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=260764"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260764\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}