Sha256: 4c3e069558218eae6f2a0387f08e95cb5cf9d4c50059e3662914d4a687d57800
Contents?: true
Size: 711 Bytes
Versions: 2
Compression:
Stored size: 711 Bytes
Contents
module Alf module Types # # Data type for being a valid attribute name # class AttrName < Symbol extend Myrrha::Domain def self.predicate @predicate ||= lambda{|s| s.to_s =~ /^[a-zA-Z0-9_]+$/} end def self.coerce(arg) if arg.respond_to?(:to_sym) sym = arg.to_sym return sym if self.===(sym) end raise ArgumentError, "Unable to coerce `#{arg.inspect}` to AttrName" end def self.from_argv(argv, opts = {}) raise ArgumentError if argv.size > 1 coerce(argv.first || opts[:default]) end end # class AttrName end # module Types end # module Alf
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alf-0.10.1 | lib/alf/types/attr_name.rb |
alf-0.10.0 | lib/alf/types/attr_name.rb |