Sha256: 720823b93c6646fba8471351e7dfc77099ec2ddb1d57bf70ea786dfd07bcc4e8
Contents?: true
Size: 878 Bytes
Versions: 5
Compression:
Stored size: 878 Bytes
Contents
require "peto/mixin/peto_class" <%- name = @target[:name].camelize -%> <%- args = @target[:args] -%> module Peto class <%= name %> include PetoClass def initialize(args={}) <%- args.each do |arg| -%> <%- if arg[:array_type] -%> @<%= arg[:name] %> = [] # for <%= arg[:array_type] %> <%- else -%> @<%= arg[:name] %> = nil <%- end -%> <%- end -%> set_by_hash(args) raise_errors unless valid? end <%- args.each do |arg| -%> attr_reader :<%= arg[:name] %> <%- end -%> def members [<%= args.map{|arg| ":#{arg[:name]}"}.join(",") %>] end def types {<%= args.map{|arg| ":#{arg[:name]} => #{arg[:type]}"}.join(",") %>} end def arrays {<%= args.select{|arg|arg[:array_type]}.map{|arg| ":#{arg[:name]} => #{arg[:array_type]}"}.join(",") %>} end end end
Version data entries
5 entries across 5 versions & 1 rubygems