Module: Attribution
- Defined in:
- lib/attribution.rb,
lib/attribution/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- BOOLEAN_TRUE_STRINGS =
['y','yes','t','true']
- VERSION =
"0.3.1"
Class Method Summary collapse
Instance Method Summary collapse
-
#attributes(*associations) ⇒ Object
TODO: Use associations argument as a way to specify which associations should be included.
- #initialize(attrs = {}) ⇒ Object
Class Method Details
.included(cls) ⇒ Object
7 8 9 |
# File 'lib/attribution.rb', line 7 def self.included(cls) cls.extend(ClassMethods) end |
Instance Method Details
#attributes(*associations) ⇒ Object
TODO: Use associations argument as a way to specify which associations should be included
24 25 26 27 28 29 |
# File 'lib/attribution.rb', line 24 def attributes(*associations) self.class.attribute_names.inject({}) do |attrs, attr| attrs[attr] = send(attr) attrs end end |
#initialize(attrs = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/attribution.rb', line 11 def initialize(attrs={}) attrs = JSON.parse(attrs) if attrs.is_a?(String) attrs.each do |k,v| setter = "#{k}=" if respond_to?(setter) send(setter, v) else instance_variable_set("@#{k}", v) end end end |