aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/obscuren/otto/registry
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/obscuren/otto/registry')
-rw-r--r--Godeps/_workspace/src/github.com/obscuren/otto/registry/README.markdown51
-rw-r--r--Godeps/_workspace/src/github.com/obscuren/otto/registry/registry.go47
2 files changed, 98 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/obscuren/otto/registry/README.markdown b/Godeps/_workspace/src/github.com/obscuren/otto/registry/README.markdown
new file mode 100644
index 000000000..ba2d38909
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/obscuren/otto/registry/README.markdown
@@ -0,0 +1,51 @@
+# registry
+--
+ import "github.com/robertkrimen/otto/registry"
+
+Package registry is an expirmental package to facillitate altering the otto
+runtime via import.
+
+This interface can change at any time.
+
+## Usage
+
+#### func Apply
+
+```go
+func Apply(callback func(Entry))
+```
+
+#### type Entry
+
+```go
+type Entry struct {
+}
+```
+
+
+#### func Register
+
+```go
+func Register(source func() string) *Entry
+```
+
+#### func (*Entry) Disable
+
+```go
+func (self *Entry) Disable()
+```
+
+#### func (*Entry) Enable
+
+```go
+func (self *Entry) Enable()
+```
+
+#### func (Entry) Source
+
+```go
+func (self Entry) Source() string
+```
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/Godeps/_workspace/src/github.com/obscuren/otto/registry/registry.go b/Godeps/_workspace/src/github.com/obscuren/otto/registry/registry.go
new file mode 100644
index 000000000..966638ac4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/obscuren/otto/registry/registry.go
@@ -0,0 +1,47 @@
+/*
+Package registry is an expirmental package to facillitate altering the otto runtime via import.
+
+This interface can change at any time.
+*/
+package registry
+
+var registry []*Entry = make([]*Entry, 0)
+
+type Entry struct {
+ active bool
+ source func() string
+}
+
+func newEntry(source func() string) *Entry {
+ return &Entry{
+ active: true,
+ source: source,
+ }
+}
+
+func (self *Entry) Enable() {
+ self.active = true
+}
+
+func (self *Entry) Disable() {
+ self.active = false
+}
+
+func (self Entry) Source() string {
+ return self.source()
+}
+
+func Apply(callback func(Entry)) {
+ for _, entry := range registry {
+ if !entry.active {
+ continue
+ }
+ callback(*entry)
+ }
+}
+
+func Register(source func() string) *Entry {
+ entry := newEntry(source)
+ registry = append(registry, entry)
+ return entry
+}