Created
May 1, 2012 15:07
-
-
Save dcrosby42/2568642 to your computer and use it in GitHub Desktop.
Conject blog post samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
construct_with :chassis, :engine, :highway | |
end | |
car = Conject.default_object_context[:car] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable caching for specific objects: | |
my_context.configure_object engine: {cache: false} | |
# Custom object construction via proc or lambda: | |
my_context.configure_object chassis: {construct: lambda do "The Chassis" end} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChartPresenter | |
construct_with :chart_model, :chart_view | |
end | |
main_context.in_subcontext do |sub| | |
sub[:chart_model] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Galaxy | |
construct_with :this_object_context | |
def spawn_new_solar_system | |
this_object_context.in_subcontext do |subcontext| | |
subcontext[:sun].genesis | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment