Module: TicketEvolution::Model::ParentalBehavior
- Included in:
- Account, Affiliate, Client, Commission, CreditMemo, Order, Payment
- Defined in:
- lib/ticket_evolution/core/model/parental_behavior.rb
Instance Method Summary collapse
Instance Method Details
#new_ostruct_member(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ticket_evolution/core/model/parental_behavior.rb', line 24 def new_ostruct_member(name) name = name.to_sym unless self.respond_to?(name) class << self; self; end.class_eval do define_method(name) { @table[name.to_sym] } define_method("#{name}=") { |x| modifiable[name] = process_datum(x, name) } end end name rescue NameError => e super end |
#process_datum(v, k = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ticket_evolution/core/model/parental_behavior.rb', line 11 def process_datum(v, k = nil) v = super if k and v.is_a? Array and v.singleton_class.ancestors.first == Array e = "#{self.plural_class_name}::#{k.to_s.chomp('=').camelize}".constantize.new({ :parent => endpoint }) v.extend(TicketEvolution::EndpointBehavior) v.endpoint = e end ensure return v end |