Module: ActsAsAccount::ActiveRecordExtension::ClassMethods
- Defined in:
- lib/acts_as_account/active_record_extensions.rb
Instance Method Summary collapse
Instance Method Details
#has_account(name = :default) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/acts_as_account/active_record_extensions.rb', line 13 def has_account(name = :default) has_one :"#{name}_account", -> { where name: name }, class_name: "ActsAsAccount::Account", as: :holder unless instance_methods.include?('accounts') has_many :accounts, class_name: "ActsAsAccount::Account", as: :holder end end |
#has_global_account(name) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/acts_as_account/active_record_extensions.rb', line 30 def has_global_account(name) class_eval " def account\n ActsAsAccount::Account.for(:\#{name})\n end\n EOS\nend\n" |
#is_reference ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/acts_as_account/active_record_extensions.rb', line 21 def is_reference has_many :postings, class_name: "ActsAsAccount::Posting", as: :reference class_eval " def booked?\n postings.any?\n end\n EOS\nend\n" |