Skip to content

Commit

Permalink
Extract ActiveYaml base class
Browse files Browse the repository at this point in the history
We use universal config root path.
  • Loading branch information
ashchan committed Jul 27, 2014
1 parent e925f73 commit 338ca28
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
3 changes: 3 additions & 0 deletions app/models/active_yaml_base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ActiveYamlBase < ActiveYaml::Base
set_root_path "#{Rails.root}/config"
end
4 changes: 1 addition & 3 deletions app/models/currency.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
class Currency < ActiveYaml::Base
class Currency < ActiveYamlBase
include International
include ActiveHash::Associations

set_root_path "#{Rails.root}/config"

def self.hash_codes
@codes ||= Hash[*all.map do |x| [x.code, x.id] end.flatten].symbolize_keys
end
Expand Down
4 changes: 1 addition & 3 deletions app/models/deposit_channel.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class DepositChannel < ActiveYaml::Base
set_root_path "#{Rails.root}/config"

class DepositChannel < ActiveYamlBase
include Channelable
include HashCurrencible
include International
Expand Down
4 changes: 1 addition & 3 deletions app/models/market.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
# _cny_, buyers buy in _btc_ with _cny_. _btc_ is the `target`, while _cny_
# is the `price`.

class Market < ActiveYaml::Base
class Market < ActiveYamlBase
include Enumerizeable

set_root_path "#{Rails.root}/config"

attr :name, :target_unit, :price_unit

# TODO: our market id is the opposite of conventional market name.
Expand Down
4 changes: 1 addition & 3 deletions app/models/withdraw_channel.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class WithdrawChannel < ActiveYaml::Base
set_root_path "#{Rails.root}/config"

class WithdrawChannel < ActiveYamlBase
include Channelable
include HashCurrencible
include International
Expand Down

0 comments on commit 338ca28

Please sign in to comment.