Class: MagicUserstamp::Config::Pattern
- Inherits:
-
Object
- Object
- MagicUserstamp::Config::Pattern
- Defined in:
- lib/magic_userstamp/config.rb
Instance Attribute Summary collapse
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#event_name ⇒ Object
readonly
Returns the value of attribute event_name.
-
#options_for_stampable_on ⇒ Object
readonly
Returns the value of attribute options_for_stampable_on.
-
#stampable_class_names ⇒ Object
readonly
Returns the value of attribute stampable_class_names.
-
#stamper_attr_name ⇒ Object
readonly
Returns the value of attribute stamper_attr_name.
-
#stamper_class_name ⇒ Object
readonly
Returns the value of attribute stamper_class_name.
Instance Method Summary collapse
- #args_for_stampable_on(column_name = nil) ⇒ Object
-
#initialize(event_name, column_name, options = nil) ⇒ Pattern
constructor
A new instance of Pattern.
- #stampable?(klass, column_name) ⇒ Boolean
Constructor Details
#initialize(event_name, column_name, options = nil) ⇒ Pattern
Returns a new instance of Pattern.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/magic_userstamp/config.rb', line 91 def initialize(event_name, column_name, = nil) @event_name = event_name @column_name = column_name = { :stampable_class_names => nil, :stamper_class_name => 'User', :stamper_attr_name => nil # sholuld not be only 'id' but PK column name }.update( || {}) @stampable_class_names = .delete(:stampable_class_names) MagicUserstamp::Stampable.() @options_for_stampable_on = @stamper_class_name = [:stamper_class_name] @stamper_attr_name = [:stamper_attr_name] end |
Instance Attribute Details
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
87 88 89 |
# File 'lib/magic_userstamp/config.rb', line 87 def column_name @column_name end |
#event_name ⇒ Object (readonly)
Returns the value of attribute event_name.
87 88 89 |
# File 'lib/magic_userstamp/config.rb', line 87 def event_name @event_name end |
#options_for_stampable_on ⇒ Object (readonly)
Returns the value of attribute options_for_stampable_on.
89 90 91 |
# File 'lib/magic_userstamp/config.rb', line 89 def @options_for_stampable_on end |
#stampable_class_names ⇒ Object (readonly)
Returns the value of attribute stampable_class_names.
87 88 89 |
# File 'lib/magic_userstamp/config.rb', line 87 def stampable_class_names @stampable_class_names end |
#stamper_attr_name ⇒ Object (readonly)
Returns the value of attribute stamper_attr_name.
88 89 90 |
# File 'lib/magic_userstamp/config.rb', line 88 def stamper_attr_name @stamper_attr_name end |
#stamper_class_name ⇒ Object (readonly)
Returns the value of attribute stamper_class_name.
88 89 90 |
# File 'lib/magic_userstamp/config.rb', line 88 def stamper_class_name @stamper_class_name end |
Instance Method Details
#args_for_stampable_on(column_name = nil) ⇒ Object
111 112 113 |
# File 'lib/magic_userstamp/config.rb', line 111 def args_for_stampable_on(column_name = nil) [event_name, {:attribute => column_name || self.column_name}.update(@options_for_stampable_on)] end |
#stampable?(klass, column_name) ⇒ Boolean
106 107 108 109 |
# File 'lib/magic_userstamp/config.rb', line 106 def stampable?(klass, column_name) (stampable_class_names.nil? ? true : stampable_class_names.include?(klass.name)) && (column_name.to_s == self.column_name.to_s) end |