Sha256: ce4c91b62283b273aa6e21d656063fa12d3015c0e8cb3a08609af81d185cbbd3
Contents?: true
Size: 834 Bytes
Versions: 1
Compression:
Stored size: 834 Bytes
Contents
module TicketingHub class Schema KNOWN_ATTRIBUTE_TYPES = %w(string text integer float decimal datetime timestamp time date binary boolean) def [] key @attrs[key.to_s].to_sym end def initialize &block @attrs = Hash.new instance_eval &block if block_given? end def keys @attrs.keys end def attribute name, type, options = {} raise ArgumentError, "Unknown Attribute type: #{type.inspect} for key: #{name.inspect}" unless type.nil? || Schema::KNOWN_ATTRIBUTE_TYPES.include?(type.to_s) tap { @attrs[name.to_s] = [type.to_s, options] } end KNOWN_ATTRIBUTE_TYPES.each do |type| define_method type do |*args| options = args.last.is_a?(::Hash) ? args.pop : {} args.each { |name| attribute name, type, options } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ticketinghub-0.0.2 | lib/ticketing_hub/schema.rb |