Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aloon committed Oct 30, 2012
1 parent 9c11d87 commit 64c02d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ now you can:

```ruby
MyClass.find(1).status
# returns #<Status:0x00 @id=0, @desc="NEW">
# returns #<Status:0x00 @id=0, @description="NEW">

MyClass.find(1).status.desc
MyClass.find(1).status.description
# returns "NEW"

element = MyClass.find(1)
Expand All @@ -51,5 +51,5 @@ now you can:
# this save element.status_id with the value 1

Status.get
#returns [#<Status:0x00 @id=0, @desc="NEW">, #<Status:0x00 @id=1, @desc="GENERATING">, #<Status:0x00 @id=2, @desc="RUN">, #<Status:0x00 @id=3, @desc="DELETING">]
#returns [#<Status:0x00 @id=0, @description="NEW">, #<Status:0x00 @id=1, @description="GENERATING">, #<Status:0x00 @id=2, @description="RUN">, #<Status:0x00 @id=3, @description="DELETING">]
```
2 changes: 1 addition & 1 deletion lib/has_dictionary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
module HasDictionary

if defined?(ActiveRecord::Base)
#require 'has_dictionary/has_dictionary'
require 'has_dictionary/has_dictionary'
require 'has_dictionary/dictionary'
#ActiveRecord::Base.extend ActsAsVotable::Extenders::Votable
#ActiveRecord::Base.extend HasDictionary::Dictionary
Expand Down
6 changes: 3 additions & 3 deletions lib/has_dictionary/dictionary.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Dictionary
attr_reader :id, :desc
attr_reader :id, :description

def initialize id, desc
def initialize id, description
@id = id
@desc = desc
@description = description
end

def self.add_item(key,value)
Expand Down
28 changes: 12 additions & 16 deletions lib/has_dictionary/has_dictionary.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module ActiveRecord

module HasDictionary

def self.included( base ) #:nodoc:
base.send( :extend, ActsMethods )
extend ActiveSupport::Concern

included do
end

module ActsMethods #:nodoc:


module ClassMethods
def has_dictionary(options = {})
class_attribute :dic_options

Expand All @@ -17,13 +14,12 @@ def has_dictionary(options = {})
eval "#{dic_options[:dic_class]}.get self.#{dic_options[:field]}"
}
end

end
end

module Base

def squawk(string)
write_attribute(self.class.yaffle_text_field, string.to_squawk)
end

end
end

ActiveRecord::Base.send :include, HasDictionary

0 comments on commit 64c02d7

Please sign in to comment.