This file contains hidden or 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
| module Mack | |
| module Notifier | |
| module Adapters # :nodoc: | |
| # Converts a Mack::Notifier object into a TMail object. | |
| class Tmail < Mack::Notifier::Adapters::Base | |
| # Returns the underlying TMail object. | |
| # Raises Mack::Errors::UnconvertedNotifier if the convert method hasn't | |
| # been called first. | |
| def transformed |
This file contains hidden or 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
| it "should namespace hashes" do | |
| configatron.should_not respond_to(:cartoon) | |
| File.open(@futurama, 'w') do |f| | |
| f.puts %{ | |
| cartoon: | |
| characters: | |
| fry: human | |
| leela: mutant |
This file contains hidden or 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
| configatron.configure_from_hash({:email => | |
| {:pop => {:address => 'pop.example.com', :port => 110}}, | |
| :smtp => {:address => 'smtp.example.com'}}) |
This file contains hidden or 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
| # config.yml: | |
| email: | |
| pop: | |
| address: pop.example.com | |
| port: 110 | |
| smtp: | |
| address: smtp.example.com | |
| # your ruby app: | |
| configatron.configure_from_yaml('config.yml') |
This file contains hidden or 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
| configatron.email.pop.address # => 'pop.example.com' | |
| configatron.email.pop.port # => 110 | |
| # and so on... |
This file contains hidden or 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
| # Setting parameters with Configatron 1.x: | |
| configatron do |c| | |
| c.foo = :bar | |
| c.namespace(:mack) do |mack| | |
| mack.hello = 'Hello' | |
| end | |
| end | |
| # Setting parameters with Configatron 2.x: | |
| configatron.foo = :bar |
This file contains hidden or 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
| configatron.allow_admins = false | |
| configatron.protect(:allow_admins) | |
| configatron.allow_admins = true # Raises Configatron::ProtectedParameter | |
| configatron.letters.a = 'A' | |
| configatron.letters.b = 'B' | |
| configatron.protect(:letters) | |
| configatron.letters.a = 'a' # Raises Configatron::ProtectedParameter |
This file contains hidden or 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
| configatron.email = 'me@example.com' | |
| configatron.email # => 'me@example.com' | |
| configatron.set_default(:name, 'Mark Bates') | |
| configatron.name # => 'Mark Bates' | |
| # If the parameter is already set, it won't be set again | |
| configatron.set_default(:name, 'Me') | |
| configatron.name # => 'Mark Bates' | |
| configatron.set_default(:email, 'you@example.com') | |
| configatron.email # => 'me@example.com' |
This file contains hidden or 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
| require 'rubygems' | |
| require 'configatron' | |
| configatron.one = 1 | |
| configatron.letters.a = 'A' | |
| configatron.letters.b = 'B' | |
| configatron.numbers.small.one = 1 | |
| configatron.numbers.small.others = [2,3] | |
| configatron.numbers.big.one.hundred = '100' | |
This file contains hidden or 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
| require 'rubygems' | |
| require 'dm-core' | |
| require 'dm-aggregates' | |
| DataMapper.logger = DataMapper::Logger.new(STDOUT, :debug) | |
| DataMapper.setup(:default, 'sqlite3:///memory') | |
| class Person | |
| include DataMapper::Resource | |
| property :name, String, :key=> true |