Sha256: 452186b300f47416e2a7e67259bf4ce3f46105b17318a241ba3051c73905a56a
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module CurlyMustache module Attributes module Types DEFAULT_ATTRIBUTE_TYPES = %w[array integer string date time datetime boolean float].freeze def self.included(mod) mod.class_eval{ class_inheritable_accessor :attribute_types } mod.attribute_types = DEFAULT_ATTRIBUTE_TYPES.dup mod.extend(ClassMethods) mod.send(:include, InstanceMethods) end module InstanceMethods private def attribute_type(name) self.class.attribute_definitions[name.to_sym][:type] end end # end module InstanceMethods module ClassMethods def valid_attribute_type?(type) self.attribute_types.include?(type.to_s) end def check_attribute_type(type) raise InvaildAttributeType, "unexpected attribute type: #{type}" unless valid_attribute_type?(type) end end # end module ClassMethods end # end module Types end # end module Attributes end # end module CurlyMustache
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cjbottaro-curly_mustache-0.0.0 | lib/attributes/types.rb |