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 <<-EOS def account ActsAsAccount::Account.for(:#{name}) end EOS end |
#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 <<-EOS def booked? postings.any? end EOS end |