{"id":282830,"date":"2016-12-21T16:15:03","date_gmt":"2016-12-21T13:15:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282830"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282830","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00abProtocol\u00bb \u0432 Ruby"},"content":{"rendered":"<p>\u0412 Elixir\u2019\u0435 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f <code>behaviours<\/code>, \u0438\u043b\u0438 \u00ab\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432\u00bb, \u0435\u0441\u043b\u0438 \u0443\u0433\u043e\u0434\u043d\u043e. \u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a <a href=\"http:\/\/elixir-lang.org\/getting-started\/protocols.html\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>:<\/p>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b\u00a0\u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0432 Elixir. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b.<\/p><\/blockquote>\n<p>\u041e \u0447\u0435\u043c \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435? \u041d\u0443, \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 Elixir, \u0438\u043b\u0438, \u043a\u0430\u043a \u0438\u0445 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u00ab\u0442\u0435\u0440\u043c\u044b\u00bb, \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b. \u0412 Ruby \u043c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445, \u0438 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u0412 Elixir\u2019\u0435 \u044d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043a\u0430\u0436\u0434\u044b\u0439, \u043a\u0442\u043e \u0438\u0437\u0443\u0447\u0430\u043b \u041e\u041e\u041f, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c: \u043a\u043b\u0430\u0441\u0441 <code>Animal<\/code>, \u0441 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 <code>sound<\/code>:<a name=\"habracut\"><\/a><\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">class Animal   def sound     raise &quot;\u042f\u00a0\u2014 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u0437\u0432\u0435\u0440\u044c, \u044f \u0445\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c \u0442\u0438\u0448\u0438\u043d\u044b (\u0438 \u0442\u0430\u0439\u043d\u044b \u043f\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443).&quot;   end end  class Dog &lt; Animal   def sound     puts &quot;[LOG] \u042f \u0441\u043e\u0431\u0430\u043a\u0430, \u044f \u043b\u0430\u044e.&quot;     &quot;\u0433\u0430\u0432&quot;   end end  class Cat &lt; Animal   def sound     puts &quot;[LOG] \u042f \u043a\u043e\u0442, \u044f \u043c\u044f\u0443\u0447\u0443&quot;     &quot;\u043c\u044f\u0443&quot;   end end<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>sound<\/code> \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e, \u043d\u0435 \u0443\u0442\u0440\u0443\u0436\u0434\u0430\u044f \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430. \u0412 Elixir\u2019\u0435 \u0432\u0441\u0435 \u0438\u043d\u0430\u0447\u0435, \u0432\u0435\u0434\u044c \u0442\u0430\u043c \u043d\u0435\u0442 \u00ab\u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445\u00bb. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0442\u0438\u043f\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u0433\u0434\u0435 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 <code>&quot;#{object}&quot;<\/code>), \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b.<\/p>\n<p>  <\/p>\n<p><em>\u0417\u0430\u043c\u0435\u0442\u043a\u0430 \u043d\u0430 \u043f\u043e\u043b\u044f\u0445:<\/em> \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/elixir-lang.org\/getting-started\/typespecs-and-behaviours.html#behaviours\"><code>behaviours<\/code><\/a>, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u0445.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b<\/strong>\u00a0\u2014 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <code>defprotocol<\/code>. \u0414\u043b\u044f <em>\u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e<\/em> \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435, \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code>defprotocol Noisy do   @doc &quot;Produces a sound for the animal given&quot;   def sound(animal) end<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 <code>defimpl<\/code>:<\/p>\n<p>  <\/p>\n<pre><code>defimpl Noisy, for: Dog do   def sound(animal), do: &quot;woof&quot; end  defimpl Noisy, for: Cat do   def sound(animal), do: &quot;meow&quot; end<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u044f\u0441\u044c \u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u0445, \u0447\u0442\u043e \u0442\u0430\u043c \u0437\u0430 \u0437\u0432\u0435\u0440\u044c:<\/p>\n<p>  <\/p>\n<pre><code>ExtrernalSource.animal |&gt; Noisy.sound<\/code><\/pre>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u041b\u0430\u0434\u043d\u043e. \u0410 \u0437\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0432 \u0440\u0443\u0431\u0438? \u0423 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c, \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0440\u0430\u0437\u0432\u0435 \u043d\u0435\u0442? \u041d\u0443 \u0434\u0430. \u0418 \u043d\u0435\u0442. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u0443\u043c\u0435\u0441\u0442\u043d\u043e, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0449\u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0435 \u043d\u0430\u0448\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u041f\u0443\u0442\u044c \u0420\u0435\u043b\u044c\u0441, \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439 \u0448\u0438\u0440\u043e\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u0440\u0443\u0431\u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f DHH (\u0414\u0430\u0432\u0438\u0434\u0443 \u0425\u0430\u0439\u043d\u0435\u043c\u0430\u0439\u0435\u0440\u0443 \u0425\u0430\u043d\u0441\u0441\u043e\u043d\u0443, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044e Ruby on Rails\u00a0\u2014 \u043f\u0435\u0440\u0435\u0432.),\u00a0\u2014 \u044d\u0442\u043e \u043c\u0430\u043d\u043a\u0438\u043f\u0430\u0442\u0447\u0438\u043d\u0433. \u0418\u0440\u043e\u043d\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044f \u043b\u0438\u0447\u043d\u043e \u043b\u044e\u0431\u043b\u044e \u043c\u0430\u043d\u043a\u0438\u043f\u0430\u0442\u0447\u0438\u043d\u0433.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0432\u0441\u0435 \u0436\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u0445\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>Integer<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u0430\u043c\u0438, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 <code>to_days<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u043c\u0435\u0441\u0442\u043e <code>something.to_days<\/code> \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 <code>DateGuru.to_days(something)<\/code>. \u0412\u0435\u0441\u044c \u043a\u043e\u0434, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u0442 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0434\u0430\u0442\u0430\u043c\u0438, \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044f, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0448\u0435\u0442, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u042f \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043b\u0443\u0447\u0448\u0435. \u042f \u0433\u043e\u0432\u043e\u0440\u044e, \u0447\u0442\u043e \u043e\u043d \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u044d\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c <code>DSL<\/code> \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u0432 \u0440\u0443\u0431\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0433\u043e. \u041d\u0430\u0447\u043d\u0435\u043c, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0441 \u0442\u0435\u0441\u0442\u043e\u0432. \u0412\u043e\u0442 \u0442\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">module Protocols::Arithmetics   include Dry::Protocol    defprotocol do     defmethod :add, :this, :other     defmethod :subtract, :this, :other     defmethod :to_s, :this      def multiply(this, other)       raise &quot;\u0423\u043c\u0435\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0446\u0435\u043b\u043e\u0435&quot; unless other.is_a?(Integer)       (1...other).inject(this) { |memo,| memo + this }     end   end    defimpl Protocols::Arithmetics, target: String do     def add(this, other)       this + other     end      def subtract(this, other)       this.gsub \/#{other}\/, ''     end      def to_s       this     end   end    defimpl target: [Integer, Float], delegate: :to_s, map: { add: :+, subtract: :- } end<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434. \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Arithmetics<\/code>, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0434\u043b\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u0430\u0441\u0441\u0430, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 (<code>multiply<\/code>) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e. \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430: <code>Arithmetics.add(42, 3) #\u21d2 45<\/code>. \u041d\u0430\u0448 <code>DSL<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0438 \u044f\u0432\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043d\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u044b\u0439 \u0438 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0443\u0436 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c, \u043d\u043e \u043e\u043d \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u043d\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041f\u043e\u0440\u0430 \u043a \u043d\u0438\u043c \u0443\u0436\u0435 \u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">expect(Protocols::Adder.add(5, 3)).to eq(8) expect(Protocols::Adder.add(5.5, 3)).to eq(8.5) expect(Protocols::Adder.subtract(5, 10)).to eq(-5) expect(Protocols::Adder.multiply(5, 3)).to eq(15) expect do   Protocols::Adder.multiply(5, 3.5) end.to raise_error(RuntimeException, &quot;We can multiply by integers only&quot;)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0443 \u0432\u043e\u0442, \u043c\u044b \u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u042d\u0442\u043e \u043d\u0430 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u0438\u043d-\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c. \u041c\u044b \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code>BlackTie<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0442\u0443\u0442 \u0440\u0430\u0437\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b. \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u0438 \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">module BlackTie   class &lt;&lt; self     def protocols       @protocols ||= Hash.new { |h, k| h[k] = h.dup.clear }     end      def implementations       @implementations ||= Hash.new { |h, k| h[k] = h.dup.clear }     end   end   ...<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0417\u0430\u043c\u0435\u0442\u043a\u0430 \u043d\u0430 \u043f\u043e\u043b\u044f\u0445:<\/em> \u0442\u0440\u044e\u043a \u0441 <code>default_proc<\/code> \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0445\u044d\u0448\u0430 (<code>Hash.new { |h, k| h[k] = h.dup.clear }<\/code>) \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u044d\u0448 \u0441 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c \u00ab\u0433\u043b\u0443\u0431\u043e\u043a\u0438\u043c\u00bb \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c (\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0445\u044d\u0448).<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <code>defmethod<\/code> \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430: \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439 \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 (\u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u044d\u0448\u0435 <code>@protocols<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">def defmethod(name, *params)   BlackTie.protocols[self][name] = params end<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043a\u043e\u0432\u044b\u0440\u0438\u0441\u0442\u043e (\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u043e\u043f\u0443\u0449\u0435\u043d\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043c\u0443\u0441\u043e\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443; <a href=\"https:\/\/github.com\/am-kantox\/dry-behaviour\/blob\/master\/lib\/dry\/behaviour\/black_tie.rb#L19\">\u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u0443\u0442<\/a>).<\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">def defprotocol   raise if BlackTie.protocols.key?(self) || !block_given?    ims = instance_methods(false)   class_eval(&amp;Proc.new)   (instance_methods(false) - ims).each { |m| class_eval { module_function m } }    singleton_class.send :define_method, :method_missing do |method, *args|     raise Dry::Protocol::NotImplemented.new(:method, self.inspect, method)   end    BlackTie.protocols[self].each do |method, *|     singleton_class.send :define_method, method do |receiver = nil, *args|       impl = receiver.class.ancestors.lazy.map do |c|         BlackTie.implementations[self].fetch(c, nil)       end.reject(&amp;:nil?).first        raise Dry::Protocol::NotImplemented.new(:protocol, self.inspect, receiver.class) unless impl       impl[method].(*args.unshift(receiver))     end   end end<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u043b\u043e\u043a\u0430. \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0432\u0441\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u043b\u043e\u043a, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044f, \u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c. \u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u044b \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <code>module_function<\/code>. \u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0431\u043b\u043e\u043a\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <code>method_missing<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u044b\u0431\u0440\u043e\u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441 \u0432\u043d\u044f\u0442\u043d\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b, \u043b\u0438\u0431\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u044f \u0438\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u0430\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0438\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u0432\u043d\u044f\u0442\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430.<\/p>\n<p>  <\/p>\n<p>\u041d\u0443, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>defimpl<\/code>. \u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u0442\u043e\u0436\u0435 \u0441\u043b\u0435\u0433\u043a\u0430 \u0443\u043f\u0440\u043e\u0449\u0435\u043d, \u043f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0442\u0430\u043c \u0436\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">def defimpl(protocol = nil, target: nil, delegate: [], map: {})   raise if target.nil? || !block_given? &amp;&amp; delegate.empty? &amp;&amp; map.empty?    # builds the simple map out of both delegates and map   mds = normalize_map_delegates(delegate, map)    Module.new do     mds.each(&amp;DELEGATE_METHOD.curry[singleton_class])     # delegation impl     singleton_class.class_eval(&amp;Proc.new) if block_given? # block takes precedence   end.tap do |mod|     mod.methods(false).tap do |meths|       (BlackTie.protocols[protocol || self].keys - meths).each_with_object(meths) do |m, acc|         logger.warn(&quot;Implicit delegate #{(protocol || self).inspect}##{m} to #{target}&quot;)         DELEGATE_METHOD.(mod.singleton_class, [m] * 2)         acc &lt;&lt; m       end     end.each do |m|       [*target].each do |tgt|         BlackTie.implementations[protocol || self][tgt][m] = mod.method(m).to_proc       end     end   end end module_function :defimpl<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u0432\u0437\u0438\u0440\u0430\u044f \u043d\u0430 \u043a\u0430\u0436\u0443\u0449\u0443\u044e\u0441\u044f \u043d\u0435\u0432\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043e\u043d \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442: \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0430 \u043d\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u0412\u044b\u0437\u043e\u0432 <code>Arithmetics.add(5, 3)<\/code> \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u0440\u0435\u0441\u0438\u0432\u0435\u0440\u0430 (<code>5<\/code>), \u0440\u0435\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (<code>defimpl Arithmetics, target: Integer<\/code>) \u0438 \u0432\u044b\u0437\u043e\u0432\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0437\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 (<code>:+<\/code>). \u042d\u0442\u043e \u0432\u0441\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0439<\/p>\n<p>  <\/p>\n<pre><code class=\"ruby\">defimpl target: [Integer, ...], ..., map: { add: :+, ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u0431\u0435\u0434\u0438\u0442\u044c \u0432\u0430\u0441 \u0432 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0435\u0449\u0435 \u0440\u0430\u0437. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Tax<\/code> (\u043d\u0430\u043b\u043e\u0433). \u041e\u043d \u043c\u043e\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u0430\u043a <code>ItemToSell<\/code>, <code>Shipment<\/code>, <code>Employee<\/code>, <code>Lunch<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0435\u043c\u043e\u0432 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u2192 \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <a href=\"https:\/\/github.com\/am-kantox\/dry-behaviour\/\">dry-behaviour<\/a> \u0433\u0435\u043c\u0430 \u043d\u0430 github.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0439\u0442\u0435\u0441\u044c!<\/p>\n<p>  <\/p>\n<p><a href=\"http:\/\/rocket-science.ru\/hacking\/2016\/12\/19\/dry-behaviour\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438<\/a><\/p>\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=\"https:\/\/habrahabr.ru\/post\/318138\/\"> https:\/\/habrahabr.ru\/post\/318138\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 Elixir\u2019\u0435 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f <code>behaviours<\/code>, \u0438\u043b\u0438 \u00ab\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432\u00bb, \u0435\u0441\u043b\u0438 \u0443\u0433\u043e\u0434\u043d\u043e. \u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a <a href=\"http:\/\/elixir-lang.org\/getting-started\/protocols.html\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>:<\/p>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b\u00a0\u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0432 Elixir. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b.<\/p><\/blockquote>\n<p>\u041e \u0447\u0435\u043c \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435? \u041d\u0443, \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 Elixir, \u0438\u043b\u0438, \u043a\u0430\u043a \u0438\u0445 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u00ab\u0442\u0435\u0440\u043c\u044b\u00bb, \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b. \u0412 Ruby \u043c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445, \u0438 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u0412 Elixir\u2019\u0435 \u044d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043a\u0430\u0436\u0434\u044b\u0439, \u043a\u0442\u043e \u0438\u0437\u0443\u0447\u0430\u043b \u041e\u041e\u041f, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c: \u043a\u043b\u0430\u0441\u0441 <code>Animal<\/code>, \u0441 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 <code>sound<\/code>:<\/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-282830","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282830","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=282830"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282830\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}