Module: Audrey::Util
- Defined in:
- lib/audrey.rb
Overview
Audrey::Util
Constant Summary collapse
- RCLASS_FROM_ACLASS_CACHE =
rclass_from_aclass
{}
- @@CUSTOM_CLASSES =
custom_class?
{}
Class Method Summary collapse
-
.aclass_fco(aclass) ⇒ Object
————————————————————————— aclass_fco, aclass_isolate.
- .aclass_isolate(aclass) ⇒ Object
- .custom_class?(aclass) ⇒ Boolean
-
.graph_field?(aclass, hkey) ⇒ Boolean
————————————————————————— graph_field?.
-
.randstr(len = 5) ⇒ Object
————————————————————————— randstr Always returns a string consisting of just alphabetic characters.
- .rclass_from_aclass(aclass) ⇒ Object
-
.uuid ⇒ Object
————————————————————————— uuid.
Class Method Details
.aclass_fco(aclass) ⇒ Object
aclass_fco, aclass_isolate
1455 1456 1457 |
# File 'lib/audrey.rb', line 1455 def self.aclass_fco(aclass) return self.rclass_from_aclass(aclass).fco end |
.aclass_isolate(aclass) ⇒ Object
1459 1460 1461 |
# File 'lib/audrey.rb', line 1459 def self.aclass_isolate(aclass) return self.rclass_from_aclass(aclass).isolate end |
.custom_class?(aclass) ⇒ Boolean
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 |
# File 'lib/audrey.rb', line 1496 def self.custom_class?(aclass) # $tm.hrm # cache if not @@CUSTOM_CLASSES.has_key?(aclass) # puts aclass @@CUSTOM_CLASSES[aclass] = rclass_from_aclass(aclass) < Audrey::Object::Custom end # return return @@CUSTOM_CLASSES[aclass] end |
.graph_field?(aclass, hkey) ⇒ Boolean
graph_field?
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 |
# File 'lib/audrey.rb', line 1470 def self.graph_field?(aclass, hkey) # $tm.hrm if aclass and Module.const_defined?(aclass) clss = Module.const_get(aclass) 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.
1416 1417 1418 |
# File 'lib/audrey.rb', line 1416 def self.randstr(len=5) return (0...len).map { ('a'..'z').to_a[rand(26)] }.join.untaint end |
.rclass_from_aclass(aclass) ⇒ Object
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 |
# File 'lib/audrey.rb', line 1429 def self.rclass_from_aclass(aclass) if early = RCLASS_FROM_ACLASS_CACHE[aclass] return early end if Module.const_defined?(aclass) rclass = Module.const_get(aclass) if rclass < Audrey::Object RCLASS_FROM_ACLASS_CACHE[aclass] = rclass return rclass else raise 'not-custom-class: ' + aclass.to_s end else raise 'unknown-aclass: ' + aclass.to_s end end |
.uuid ⇒ Object
uuid
1403 1404 1405 |
# File 'lib/audrey.rb', line 1403 def self.uuid return SecureRandom.uuid end |