This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuildPropertyAssociationsOnExports < ActiveRecord::Migration | |
... | |
class Property < ActiveRecord::Base | |
attr_accessible :hierarchical | |
end | |
... | |
def up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RenameHierarchicalToEnumeratedInProperties < ActiveRecord::Migration | |
def change | |
rename_column(:properties, :hierarchical, :enumerated) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuildPropertyAssociationsOnExports < ActiveRecord::Migration | |
... | |
class Property < ActiveRecord::Base | |
attr_accessible :hierarchical | |
def enumerated? | |
if defined?(super) | |
super | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarkProductExportsWhichMeetAllRequirements < ActiveRecord::Migration | |
Export = Class.new(ActiveRecord::Base) | |
class ProductExport < Export | |
attr_accessible :meets_requirements | |
def meets_all_requirements? | |
# Do some complex business logic which cannot be expressed via sql query | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarkProductExportsWhichMeetAllRequirements < ActiveRecord::Migration | |
class Export < ActiveRecord::Base | |
attr_accessible :meets_requirements | |
def meets_all_requirements? | |
# Do some complex business logic which cannot be expressed via sql query | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarkProductExportsWhichMeetAllRequirements < ActiveRecord::Migration | |
class Export < ActiveRecord::Base | |
attr_accessible :meets_requirements | |
self.inheritance_column = nil | |
def meets_all_requirements? | |
# Do some complex business logic which cannot be expressed via sql query | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError: undefined method `meets_all_requirements?' for #<ProductExport:0x007fae799b32a8> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically kill jobs' worker when it finishes | |
# if it used more memory than allotted. | |
# Ali-G: Lets talk about doctors who is ending the life of people who is suffering. | |
# Ali-G What’s it got to do with the youth in Asia I mean it aiint their fault these peoples is dying, they’s thousands of miles away. | |
# Doctor: Euthanasia means mercy killing, it literally means dying well. We're not talking about the youth in Asia, (or) the youth in Africa. | |
# Ali-G: But why is you blaming that on the asian kids or whatever? | |
module Delayed | |
module Plugins | |
class YouthInAsiaPlugin < Delayed::Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WorkerExtensions | |
WorkerProcess = Struct.new(:id, :name, :app_name, :size) do | |
ONE_X_WORKER_SIZE = 512.0 | |
TWO_X_WORKER_SIZE = 1024.0 | |
def memory_ceiling | |
size == 1 ? ONE_X_WORKER_SIZE : TWO_X_WORKER_SIZE | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wouldn't it be great if you could have STI like functionality | |
# without needing to encode strings of class names in the database? | |
# Well today is your lucky day! Discriminable Model is here to help. | |
# | |
# Simply specify your models desired type column, and provide a block to | |
# do the discrimination. If you want the whole STI-esque shebang of properly | |
# typed finder methods you can supply an array of 'discriminate_types' that will | |
# be used to apply an appropriate type. | |
# | |
# class MyModel < ActiveRecord::Base |
OlderNewer