class DiningTable::Presenters::HTMLPresenterConfiguration::TagConfiguration
configuration classes that allow us to avoid implementing a deep-merge for the config hash, and are more user friendly for use in config blocks in the table definition
Attributes
__data_hash[RW]
Public Class Methods
from_hash( hash )
click to toggle source
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 49 def self.from_hash( hash ) new.merge_hash( hash ) end
new()
click to toggle source
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 13 def initialize self.__data_hash = {} end
Public Instance Methods
class()
click to toggle source
override class method (since it is a very common html attribute), and the method missing approach doesn't work here, as it returns the Ruby class by default.
Calls superclass method
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 33 def class __data_hash.key?( :class ) ? __data_hash[ :class ] : super end
initialize_copy( source )
click to toggle source
for deep dup
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 54 def initialize_copy( source ) self.__data_hash = source.__data_hash.dup end
merge_hash( hash )
click to toggle source
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 41 def merge_hash( hash ) return self if !hash hash.each do |key, value| self.send("#{ key }=", value) end self end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 17 def method_missing(name, *args, &block) if name.to_s[-1] == '=' key = name.to_s[0..-2] # strip away '=' __data_hash[ key.to_sym ] = args.first else __data_hash.key?( name ) ? __data_hash[ name ] : super end end
respond_to_missing?(method_name, *args)
click to toggle source
Calls superclass method
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 26 def respond_to_missing?(method_name, *args) return true if method_name.to_s[-1] == '=' __data_hash.key?( method_name ) ? true : super end
to_h()
click to toggle source
# File lib/dining-table/presenters/html_presenter_configuration.rb, line 37 def to_h __data_hash end