Class: Invoicing::LineItem::ClassInfo

Inherits:
ClassInfo::Base show all
Defined in:
lib/invoicing/line_item.rb

Overview

Stores state in the ActiveRecord class object

Instance Attribute Summary collapse

Attributes inherited from ClassInfo::Base

#all_args, #all_options, #current_args, #current_options, #model_class, #new_args, #previous_info

Instance Method Summary collapse

Methods inherited from ClassInfo::Base

#get, #option_defaults, #set

Constructor Details

#initialize(model_class, previous_info, args) ⇒ ClassInfo

Returns a new instance of ClassInfo.



234
235
236
237
238
239
240
241
242
243
# File 'lib/invoicing/line_item.rb', line 234

def initialize(model_class, previous_info, args)
  super
  
  begin # try to load the UUID gem
    require 'uuid'
    @uuid_generator = UUID.new
  rescue LoadError, NameError # silently ignore if gem not found
    @uuid_generator = nil
  end
end

Instance Attribute Details

#uuid_generatorObject (readonly)

:nodoc:



232
233
234
# File 'lib/invoicing/line_item.rb', line 232

def uuid_generator
  @uuid_generator
end

Instance Method Details

#method(name) ⇒ Object

Allow methods generated by CurrencyValue to be renamed as well



246
247
248
249
250
251
252
# File 'lib/invoicing/line_item.rb', line 246

def method(name)
  if name.to_s =~ /^(.*)_formatted$/
    "#{super($1)}_formatted"
  else
    super
  end
end