Class: Carbon::Registry::Registrar
- Inherits:
-
Object
- Object
- Carbon::Registry::Registrar
- Defined in:
- lib/carbon/registry.rb
Overview
Used internally when instance-eval'ing the emit_as DSL.
Instance Method Summary (collapse)
-
- (nil) provide(method_id, translation_options = {}) { ... }
Indicate that you will send in a piece of data about the emitter.
Instance Method Details
- (nil) provide(method_id, translation_options = {}) { ... }
It's suggested that you use Object#try to cheaply avoid undefined method `iata_code` for nil:NilClass. It will be available because this class includes active_support/core_ext anyway.
Indicate that you will send in a piece of data about the emitter.
Called inside of ClassMethods#emit_as blocks.
Things to note in the MyFlight example:
-
Sending :origin to Brighter Planet as :origin_airport. Otherwise Brighter Planet won't recognize :origin.
-
Saying we're keying on one code or another. Otherwise Brighter Planet will first try against full names and possibly other columns.
-
Giving blocks to pull codes from MyAircraft and MyAirline objects. Otherwise you might get a querystring like +airline=#<MyAirline [...]>+
68 69 70 71 72 73 74 |
# File 'lib/carbon/registry.rb', line 68 def provide(method_id, = {}, &blk) = .dup if block_given? [:blk] = blk end Registry.instance[@klass.name].characteristics[method_id] = end |