Sha256: 747f6bf1e8c2ad56e96a8e92c0450caa25fe39ecd448ffe9d4e26c5188fda2a6
Contents?: true
Size: 1006 Bytes
Versions: 1
Compression:
Stored size: 1006 Bytes
Contents
# frozen_string_literal: true module Tataru # base resource class class Resource class << self def state(state_name, change_behaviour) define_method "#{state_name}_change_action" do change_behaviour end define_method "_state_#{state_name}" do state_name end end def output(output_name) define_method "_output_#{output_name}" do output_name end define_method(output_name) {} end end def states list_props(:state) end def outputs list_props(:output) end %i[ begin_create begin_update begin_delete create_complete? update_complete? delete_complete? ].each do |thing| define_method(thing) { |_state| } end private def list_props(prop_type) methods.select { |x| x.to_s.start_with? "_#{prop_type}_" } .map { |x| x.to_s.sub("_#{prop_type}_", '').to_sym } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tataru-0.1.0 | lib/tataru/resource.rb |