Module: Audrey::Util
- Defined in:
- lib/audrey.rb
Overview
Audrey::Util
Constant Summary collapse
- RCLASS_FROM_FCLASS_CACHE =
rclass_from_fclass
{}
- @@CUSTOM_CLASSES =
custom_class?
{}
Class Method Summary collapse
- .custom_class?(fclass) ⇒ Boolean
-
.fclass_fco(fclass) ⇒ Object
————————————————————————— fclass_fco, fclass_isolate.
- .fclass_isolate(fclass) ⇒ Object
-
.graph_field?(fclass, hkey) ⇒ Boolean
————————————————————————— graph_field?.
-
.randstr(len = 5) ⇒ Object
————————————————————————— randstr Always returns a string consisting of just alphabetic characters.
- .rclass_from_fclass(fclass) ⇒ Object
-
.uuid ⇒ Object
————————————————————————— uuid.
Class Method Details
.custom_class?(fclass) ⇒ Boolean
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 |
# File 'lib/audrey.rb', line 1499 def self.custom_class?(fclass) # $tm.hrm # cache if not @@CUSTOM_CLASSES.has_key?(fclass) # puts fclass @@CUSTOM_CLASSES[fclass] = rclass_from_fclass(fclass) < Audrey::Object::Custom end # return return @@CUSTOM_CLASSES[fclass] end |
.fclass_fco(fclass) ⇒ Object
fclass_fco, fclass_isolate
1458 1459 1460 |
# File 'lib/audrey.rb', line 1458 def self.fclass_fco(fclass) return self.rclass_from_fclass(fclass).fco end |
.fclass_isolate(fclass) ⇒ Object
1462 1463 1464 |
# File 'lib/audrey.rb', line 1462 def self.fclass_isolate(fclass) return self.rclass_from_fclass(fclass).isolate end |
.graph_field?(fclass, hkey) ⇒ Boolean
graph_field?
1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
# File 'lib/audrey.rb', line 1473 def self.graph_field?(fclass, hkey) # $tm.hrm if fclass and Module.const_defined?(fclass) clss = Module.const_get(fclass) if clss.respond_to?('fields') if dfn = clss.fields[hkey] return dfn.graph end end end # if we get this far then it's not a graph field return false end |
.randstr(len = 5) ⇒ Object
randstr Always returns a string consisting of just alphabetic characters. String is untainted.
1419 1420 1421 |
# File 'lib/audrey.rb', line 1419 def self.randstr(len=5) return (0...len).map { ('a'..'z').to_a[rand(26)] }.join.untaint end |
.rclass_from_fclass(fclass) ⇒ Object
1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
# File 'lib/audrey.rb', line 1432 def self.rclass_from_fclass(fclass) if early = RCLASS_FROM_FCLASS_CACHE[fclass] return early end if Module.const_defined?(fclass) rclass = Module.const_get(fclass) if rclass < Audrey::Object RCLASS_FROM_FCLASS_CACHE[fclass] = rclass return rclass else raise 'not-custom-class: ' + fclass.to_s end else raise 'unknown-fclass: ' + fclass.to_s end end |
.uuid ⇒ Object
uuid
1406 1407 1408 |
# File 'lib/audrey.rb', line 1406 def self.uuid return SecureRandom.uuid end |