Johnathon E Wright
Johnathon E Wright
``` class Person < Valuable has_value :first_name has_value :last_name has_value :initials, :default => {|person| person.first_name[0] + person.last_name[0] } # needs some nil checking end ```
``` ruby class AppConfig < Valuable has_value :stripe do has_value :secret_key has_value :public_key has_value :show_test_instructions end end ```
:klass => :decimal - If BigDecimal isn't loaded, raise an appropriate error, not ConstNotFound - Do not cast non-decimal strings, like 'none' or "", to decimal.
class Retryer has_value :logger, :default => Rails.logger end results in: TypeError: can't dump File stack trace: ``` # ../gems/ruby-1.9.3-p448/gems/rspec-mocks-2.13.1/lib/rspec/mocks/extensions/marshal.rb:5:in `dump' # ../gems/ruby-1.9.3-p448/gems/rspec-mocks-2.13.1/lib/rspec/mocks/extensions/marshal.rb:5:in `dump_with_mocks' # ../gems/ruby-1.9.3-p448/gems/valuable-0.9.9/lib/valuable/utils.rb:33:in `deep_duplicate_of' # ../gems/ruby-1.9.3-p448/gems/valuable-0.9.9/lib/valuable/utils.rb:25:in `block in...
class PatronSearch has_value :ticket, :klass => Ticket end should create ticket_id=, ticket_id, ticket, ticket=, and tie all those in together.
``` class ConfirmationAide < Valuable has_value :confirmation, :klass => Confirmation end ``` results in: ``` An exception occurred running at_exit handlers Class doesn't know how to format confirmation with :klass...
``` class Unit has_collection :conversions, :klass => Conversion end Unit.new(:conversions => {:att => val}) ``` This should blow up because it isn't an array. Or work. Anything but resulting in...
g = Giraffe.new class Animal < Valuable; end; x = Animal.new(g) should say something like "That's a giraffe, I need a hash."
example use case: ``` class Interface has_value :messages do |current_value| if( current_value.messed_up ) other_default_value end end end ```